Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: make info log default level in most cases #1000

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions portalnet/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,8 @@ impl Discovery {
}

pub async fn start(&mut self) -> Result<mpsc::Receiver<TalkRequest>, String> {
info!(
enr.encoded = ?self.local_enr(),
enr.decoded = %self.local_enr(),
"Starting discv5",
);
info!(enr = %self.local_enr(), "Starting discv5 with");
debug!(enr = ?self.local_enr(), "Discv5 enr details");

self.discv5
.start()
Expand Down Expand Up @@ -401,7 +398,7 @@ impl AsyncUdpSocket<UtpEnr> for Discv5UdpSocket {
let enr = match self.discv5.cached_node_addr(src_node_id) {
Some(node_addr) => Ok(node_addr.enr),
None => {
warn!(node_id = %src_node_id, "uTP packet from unknown source");
debug!(node_id = %src_node_id, "uTP packet from unknown source");
Err(io::Error::new(
io::ErrorKind::Other,
"ENR not found for talk req destination",
Expand Down
22 changes: 11 additions & 11 deletions portalnet/src/overlay_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ where
let source = match self.find_enr(&peer) {
Some(enr) => enr,
_ => {
warn!("Received uTP payload from unknown {peer}");
debug!("Received uTP payload from unknown {peer}");
if let Some(responder) = callback {
let _ = responder.send((None, true, query_info.trace));
};
Expand Down Expand Up @@ -843,7 +843,7 @@ where
UtpDirectionLabel::Inbound,
UtpOutcomeLabel::FailedConnection,
);
warn!(
debug!(
%err,
cid.send,
cid.recv,
Expand All @@ -863,7 +863,7 @@ where
UtpDirectionLabel::Inbound,
UtpOutcomeLabel::FailedDataTx,
);
error!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), "error reading data from uTP stream, while handling a FindContent request.");
debug!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), "error reading data from uTP stream, while handling a FindContent request.");
if let Some(responder) = callback {
let _ = responder.send((None, true, query_info.trace));
};
Expand Down Expand Up @@ -1123,7 +1123,7 @@ where
UtpDirectionLabel::Outbound,
UtpOutcomeLabel::FailedConnection,
);
error!(
debug!(
%err,
%cid.send,
%cid.recv,
Expand All @@ -1134,7 +1134,7 @@ where
}
};
if let Err(err) = Self::send_utp_content(stream, &content, metrics).await {
warn!(
debug!(
%err,
%cid.send,
%cid.recv,
Expand Down Expand Up @@ -1270,7 +1270,7 @@ where
UtpDirectionLabel::Inbound,
UtpOutcomeLabel::FailedConnection,
);
error!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), content_keys = ?content_keys_string, "unable to accept uTP stream");
debug!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), content_keys = ?content_keys_string, "unable to accept uTP stream");
return;
}
};
Expand All @@ -1279,7 +1279,7 @@ where
if let Err(err) = stream.read_to_eof(&mut data).await {
metrics
.report_utp_outcome(UtpDirectionLabel::Inbound, UtpOutcomeLabel::FailedDataTx);
error!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), content_keys = ?content_keys_string, "error reading data from uTP stream, while handling an Offer request.");
debug!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), content_keys = ?content_keys_string, "error reading data from uTP stream, while handling an Offer request.");
return;
}

Expand All @@ -1297,7 +1297,7 @@ where
)
.await
{
error!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), content_keys = ?content_keys_string, "unable to process uTP payload");
debug!(%err, cid.send, cid.recv, peer = ?cid.peer.client(), content_keys = ?content_keys_string, "unable to process uTP payload");
}
});

Expand Down Expand Up @@ -1534,7 +1534,7 @@ where
UtpDirectionLabel::Outbound,
UtpOutcomeLabel::FailedConnection,
);
warn!(
debug!(
%err,
cid.send,
cid.recv,
Expand Down Expand Up @@ -1587,7 +1587,7 @@ where

// send the content to the acceptor over a uTP stream
if let Err(err) = Self::send_utp_content(stream, &content_payload, metrics).await {
warn!(
debug!(
%err,
%cid.send,
%cid.recv,
Expand Down Expand Up @@ -1712,7 +1712,7 @@ where
} else {
format!("{:?}", err)
};
error!(err, content_key = ?content_keys_string[index], "Process uTP payload tokio task failed:");
debug!(err, content_key = ?content_keys_string[index], "Process uTP payload tokio task failed:");
None
}))
.collect();
Expand Down
9 changes: 8 additions & 1 deletion trin-utils/src/log.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
use std::env;
use tracing_subscriber::EnvFilter;

pub fn init_tracing_logger() {
let rust_log = env::var(EnvFilter::DEFAULT_ENV).unwrap_or_default();
let env_filter = match rust_log.is_empty() {
true => EnvFilter::builder().parse_lossy("info,discv5=error,utp_rs=error"),
false => EnvFilter::builder().parse_lossy(rust_log),
};

tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.with_env_filter(env_filter)
.with_ansi(detect_ansi_support())
.init();
}
Expand Down