Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
node: Update logging config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cloudhead committed Mar 22, 2024
1 parent 33be2a6 commit 474df7f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
11 changes: 9 additions & 2 deletions radicle-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Options
--config <path> Config file to use (default ~/.radicle/config.json)
--force Force start even if an existing control socket is found
--listen <address> Address to listen on
--log <level> Set log level (default: info)
--version Print program version
--help Print help
"#;
Expand All @@ -40,6 +41,7 @@ Options
struct Options {
config: Option<PathBuf>,
listen: Vec<net::SocketAddr>,
log: log::Level,
force: bool,
}

Expand All @@ -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 {
Expand All @@ -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);
Expand All @@ -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..");
Expand Down
16 changes: 10 additions & 6 deletions radicle-node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 474df7f

Please sign in to comment.