From e56311739709570ea38f2d260a3d2f5411e5dd23 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Fri, 19 Sep 2025 14:56:36 +0200 Subject: [PATCH] node: Refactor logging initialization Logging initialization was infallible previously, i.e., a logger would always have to be chosen, falling back to our own logger implementation in case of failure with setting up journald submission. This lead to complexity like attempting to log errors from parsing arguments, as there is a circular dependency. Change this to make logging initialization fallible. If it fails, exit non-zero instead of falling back to another logger. This makes the initialization code slightly simpler. At the same time, make choosing the logger possible via the command line and deprecate `--log`. Note that we still default to journald if detected. --- crates/radicle-node/src/main.rs | 172 ++++++++++++++++---------- crates/radicle-systemd/src/journal.rs | 14 +-- 2 files changed, 111 insertions(+), 75 deletions(-) diff --git a/crates/radicle-node/src/main.rs b/crates/radicle-node/src/main.rs index a9f71392..3cb8fcac 100644 --- a/crates/radicle-node/src/main.rs +++ b/crates/radicle-node/src/main.rs @@ -2,6 +2,7 @@ use std::io; use std::net::SocketAddr; use std::path::PathBuf; use std::process::exit; +use std::str::FromStr; use crossbeam_channel as chan; use thiserror::Error; @@ -14,17 +15,7 @@ use radicle_node::{Runtime, VERSION}; #[cfg(unix)] use radicle_signals as signals; -/// The log level to use before reading any other value -/// from configuration. -/// -/// Note that this is different from the default value -/// of the command line argument `--log`, as it is valid -/// *even before that argument is parsed*. -/// It ensures that we log the errors parsing the -/// command line arguments, such as `--log`. -const LOG_LEVEL_DEFAULT: &log::Level = &log::Level::Warn; - -pub const HELP_MSG: &str = r#" +const HELP_MSG: &str = r#" Usage radicle-node [