mirror of
https://github.com/ratspeak/rsLXMF
synced 2026-11-22 23:10:35 +00:00
lxmd: take the log level from its own config and flags, as upstream does
This commit is contained in:
1 parent
05ab881975
commit
7edeff229e
5 files changed
+47
-28
No files matched your search
Generated
+27
-1
@@ -686,6 +686,7 @@ dependencies = [
|
||||
"rns-crypto",
|
||||
"rns-identity",
|
||||
"rns-runtime",
|
||||
"rns-tools",
|
||||
"rns-transport",
|
||||
"rns-wire",
|
||||
"serde_json",
|
||||
@@ -693,7 +694,6 @@ dependencies = [
|
||||
"thiserror 2.0.18",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -1194,6 +1194,32 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rns-tools"
|
||||
version = "1.4.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bytes",
|
||||
"clap",
|
||||
"hex",
|
||||
"nix 0.29.0",
|
||||
"rmp-serde",
|
||||
"rmpv",
|
||||
"rns-crypto",
|
||||
"rns-identity",
|
||||
"rns-interface",
|
||||
"rns-runtime",
|
||||
"rns-transport",
|
||||
"rns-wire",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serialport",
|
||||
"sha2",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rns-transport"
|
||||
version = "1.4.0"
|
||||
|
||||
@@ -21,6 +21,7 @@ rns-protocol = { path = "../rsReticulum/crates/rns-protocol", version = "~1.4.0"
|
||||
rns-transport = { path = "../rsReticulum/crates/rns-transport", version = "~1.4.0" }
|
||||
rns-runtime = { path = "../rsReticulum/crates/rns-runtime", version = "~1.4.0" }
|
||||
rns-interface = { path = "../rsReticulum/crates/rns-interface", version = "~1.4.0" }
|
||||
rns-tools = { path = "../rsReticulum/crates/rns-tools", version = "~1.4.0" }
|
||||
|
||||
# Workspace LXMF crates
|
||||
lxmf-core = { path = "crates/lxmf-core", version = "~1.4.0" }
|
||||
|
||||
@@ -15,11 +15,11 @@ rns-identity = { workspace = true }
|
||||
rns-transport = { workspace = true }
|
||||
rns-wire = { workspace = true }
|
||||
rns-crypto = { workspace = true }
|
||||
rns-tools = { workspace = true }
|
||||
clap = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
bytes = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
hex = { workspace = true }
|
||||
base64 = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -919,27 +919,21 @@ fn handle_pn_offer_request(
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_logging(verbose: u8, quiet: u8, service: bool) {
|
||||
let level = match (verbose, quiet) {
|
||||
(v, _) if v >= 3 => tracing::Level::TRACE,
|
||||
(2, _) => tracing::Level::DEBUG,
|
||||
(1, _) => tracing::Level::INFO,
|
||||
(0, 0) => {
|
||||
if service {
|
||||
tracing::Level::WARN
|
||||
} else {
|
||||
tracing::Level::INFO
|
||||
}
|
||||
}
|
||||
(_, q) if q >= 2 => tracing::Level::ERROR,
|
||||
(_, 1) => tracing::Level::WARN,
|
||||
_ => tracing::Level::INFO,
|
||||
/// Python `lxmd.program_setup`/`_remote_init`: the daemon starts from its own
|
||||
/// config's `loglevel` (a missing file is the default config it writes first);
|
||||
/// control commands never read it and start at Notice.
|
||||
fn setup_logging(args: &Args, config_dir: &Path, rns_config_dir: &Path, control_command: bool) {
|
||||
let configured = if control_command {
|
||||
None
|
||||
} else {
|
||||
rns_runtime::config::Config::from_file(&config_dir.join("config"))
|
||||
.or_else(|_| rns_runtime::config::Config::parse(example_config()))
|
||||
.ok()
|
||||
.and_then(|c| c.section("logging")?.get_int("loglevel"))
|
||||
};
|
||||
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(level)
|
||||
.with_target(false)
|
||||
.init();
|
||||
let level = rns_tools::Utility::Lxmd.loglevel(configured, args.verbose, args.quiet, false);
|
||||
let timestamps = rns_tools::config_log_timestamps(rns_config_dir);
|
||||
rns_tools::init_tracing(level, timestamps, true, std::io::stdout);
|
||||
}
|
||||
|
||||
fn now_f64() -> f64 {
|
||||
@@ -5872,10 +5866,11 @@ pub(crate) async fn main() {
|
||||
return;
|
||||
}
|
||||
|
||||
setup_logging(args.verbose, args.quiet, args.service);
|
||||
|
||||
let (config_dir, rns_config_dir) =
|
||||
resolve_config_dirs(args.config.as_deref(), args.rnsconfig.as_deref());
|
||||
let is_control_command =
|
||||
args.status || args.peers || args.sync.is_some() || args.unpeer.is_some();
|
||||
setup_logging(&args, &config_dir, &rns_config_dir, is_control_command);
|
||||
|
||||
if args.migrate_propagation_store {
|
||||
let result = (|| -> std::io::Result<()> {
|
||||
@@ -5931,8 +5926,6 @@ pub(crate) async fn main() {
|
||||
return;
|
||||
}
|
||||
|
||||
let is_control_command =
|
||||
args.status || args.peers || args.sync.is_some() || args.unpeer.is_some();
|
||||
let control_preflight = if is_control_command {
|
||||
let peer_hash = if args.status || args.peers {
|
||||
None
|
||||
|
||||
@@ -79,8 +79,7 @@ pub struct Args {
|
||||
#[arg(long)]
|
||||
pub exampleconfig: bool,
|
||||
|
||||
/// Default to warning-level logging for service use; -v/-q override this.
|
||||
/// The process remains in the foreground.
|
||||
/// Service mode; the process remains in the foreground.
|
||||
#[arg(short = 's', long)]
|
||||
pub service: bool,
|
||||
|
||||
|
||||
Reference in new issue
Block a user