From 474df7fc3cae93c7a098a3aea592587c6fc345a2 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Fri, 22 Mar 2024 13:51:21 +0100 Subject: [PATCH] node: Update logging config Promote message logging to `debug` level, and change default level to `info`. This is because `trace` level often covers details at a different level of detail than for eg. messages sent and received. This means we don't have to use `trace` level just to see the gossip. --- radicle-node/src/main.rs | 11 +++++++++-- radicle-node/src/service.rs | 16 ++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/radicle-node/src/main.rs b/radicle-node/src/main.rs index f1ff39882..e87fea26b 100644 --- a/radicle-node/src/main.rs +++ b/radicle-node/src/main.rs @@ -32,6 +32,7 @@ Options --config Config file to use (default ~/.radicle/config.json) --force Force start even if an existing control socket is found --listen
Address to listen on + --log Set log level (default: info) --version Print program version --help Print help "#; @@ -40,6 +41,7 @@ Options struct Options { config: Option, listen: Vec, + log: log::Level, force: bool, } @@ -51,6 +53,7 @@ impl Options { let mut listen = Vec::new(); let mut config = None; let mut force = false; + let mut log = log::Level::Info; while let Some(arg) = parser.next()? { match arg { @@ -66,6 +69,9 @@ impl Options { let addr = parser.value()?.parse()?; listen.push(addr); } + Long("log") => { + log = parser.value()?.parse()?; + } Long("help") | Short('h') => { println!("{HELP_MSG}"); process::exit(0); @@ -81,17 +87,18 @@ impl Options { Ok(Self { force, listen, + log, config, }) } } fn execute() -> anyhow::Result<()> { - logger::init(log::Level::Debug)?; - let home = profile::home()?; let options = Options::from_env()?; + logger::init(options.log)?; + log::info!(target: "node", "Starting node.."); log::info!(target: "node", "Version {} ({})", env!("CARGO_PKG_VERSION"), env!("GIT_HEAD")); log::info!(target: "node", "Unlocking node keystore.."); diff --git a/radicle-node/src/service.rs b/radicle-node/src/service.rs index 0af177d9a..1d3925cfb 100644 --- a/radicle-node/src/service.rs +++ b/radicle-node/src/service.rs @@ -942,10 +942,14 @@ where namespaces, clone, }) => { - debug!(target: "service", "Fetched {rid} from {remote} successfully"); + info!(target: "service", "Fetched {rid} from {remote} successfully"); for update in &updated { - debug!(target: "service", "Ref updated: {update} for {rid}"); + if update.old() != update.new() { + debug!(target: "service", "Ref updated: {update} for {rid}"); + } else { + trace!(target: "service", "Ref skipped: {update} for {rid}"); + } } self.emitter.emit(Event::RefsFetched { remote, @@ -1100,7 +1104,7 @@ where } pub fn listening(&mut self, local_addr: net::SocketAddr) { - log::info!(target: "node", "Listening on {local_addr}.."); + info!(target: "node", "Listening on {local_addr}.."); self.listening.push(local_addr); } @@ -1147,7 +1151,7 @@ where pub fn disconnected(&mut self, remote: NodeId, reason: &DisconnectReason) { let since = self.local_time(); - debug!(target: "service", "Disconnected from {} ({})", remote, reason); + info!(target: "service", "Disconnected from {} ({})", remote, reason); self.emitter.emit(Event::PeerDisconnected { nid: remote, reason: reason.to_string(), @@ -1296,7 +1300,7 @@ where match self.db.gossip_mut().announced(announcer, announcement) { Ok(fresh) => { if !fresh { - trace!(target: "service", "Ignoring stale announcement from {announcer} (t={})", self.time()); + debug!(target: "service", "Ignoring stale announcement from {announcer} (t={})", self.time()); return Ok(false); } } @@ -1617,7 +1621,7 @@ where trace!(target: "service", "Rate limiting message from {remote} ({})", peer.addr); return Ok(()); } - message.log(log::Level::Trace, remote, Link::Inbound); + message.log(log::Level::Debug, remote, Link::Inbound); trace!(target: "service", "Received message {:?} from {}", &message, peer.id);