unused/TracingSupport
Chip Senkbeil 11 months ago
parent 29be68c49d
commit 78fa43c1bf
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -3,6 +3,7 @@ use derive_more::IntoIterator;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
use std::io;
use std::ops::{Deref, DerefMut};
@ -90,3 +91,18 @@ impl DerefMut for Header {
&mut self.0
}
}
impl fmt::Display for Header {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{{")?;
for (key, value) in self.0.iter() {
let value = serde_json::to_string(value).unwrap_or_else(|_| String::from("--"));
write!(f, "\"{key}\" = {value}")?;
}
write!(f, "}}")?;
Ok(())
}
}

@ -223,6 +223,9 @@ where
.verifier(Arc::downgrade(&verifier))
.spawn(),
);
// Clean up current tasks being tracked
connection_tasks.retain(|task| !task.is_finished());
}
// Once we stop listening, we still want to wait until all connections have terminated

@ -425,7 +425,7 @@ where
let id = connection.id();
// Create local data for the connection and then process it
debug!("[Conn {id}] Officially accepting connection");
info!("[Conn {id}] Connection established");
if let Err(x) = await_or_shutdown!(handler.on_connect(id)) {
terminate_connection!(@fatal "[Conn {id}] Accepting connection failed: {x}");
}
@ -477,6 +477,10 @@ where
Ok(Some(frame)) => match UntypedRequest::from_slice(frame.as_item()) {
Ok(request) => match request.to_typed_request() {
Ok(request) => {
debug!(
"[Conn {id}] New request {} | header {}",
request.id, request.header
);
let origin_id = request.id.clone();
let ctx = RequestCtx {
connection_id: id,
@ -493,8 +497,8 @@ where
tokio::spawn(async move { handler.on_request(ctx).await });
}
Err(x) => {
if log::log_enabled!(Level::Trace) {
trace!(
if log::log_enabled!(Level::Debug) {
error!(
"[Conn {id}] Failed receiving {}",
String::from_utf8_lossy(&request.payload),
);

Loading…
Cancel
Save