From edb8851ce260d102b7bbcb6d996bee1107999c6d Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 17 Mar 2021 11:21:05 +1100 Subject: [PATCH 1/2] Fix env filter for asb 1. The asb didn't log any if the statements within main.rs 2. We were initializing unnecessary filters that don't make any sense for the asb. warp and http are not used and the harness-es are for test only. --- swap/src/trace.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/swap/src/trace.rs b/swap/src/trace.rs index 34880b33..253ca792 100644 --- a/swap/src/trace.rs +++ b/swap/src/trace.rs @@ -14,10 +14,7 @@ pub fn init_tracing(level: LevelFilter) -> Result<()> { let is_terminal = atty::is(atty::Stream::Stderr); let subscriber = FmtSubscriber::builder() - .with_env_filter(format!( - "swap={},monero_harness={},bitcoin_harness={},http=warn,warp=warn", - level, level, level - )) + .with_env_filter(format!("asb={},swap={}", level, level,)) .with_writer(std::io::stderr) .with_ansi(is_terminal) .finish(); From 9e3a104b42a3d70e97796b81c1840bbf6de39ddc Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 17 Mar 2021 11:41:28 +1100 Subject: [PATCH 2/2] Disable timestamp if we log to a non-interactive terminal A non-interactive terminal is likely something along the lines of journalctl which captures a timestamp by itself. In theory, it could also be just a logfile but we rather accept this limitation and keep the configuration surface simple rather than exposing another config switch. --- swap/src/trace.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/swap/src/trace.rs b/swap/src/trace.rs index 253ca792..2c80de97 100644 --- a/swap/src/trace.rs +++ b/swap/src/trace.rs @@ -1,5 +1,4 @@ use anyhow::Result; -use tracing::{info, subscriber}; use tracing_log::LogTracer; use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::FmtSubscriber; @@ -13,14 +12,20 @@ pub fn init_tracing(level: LevelFilter) -> Result<()> { LogTracer::init_with_filter(tracing_log::log::LevelFilter::Info)?; let is_terminal = atty::is(atty::Stream::Stderr); - let subscriber = FmtSubscriber::builder() - .with_env_filter(format!("asb={},swap={}", level, level,)) + + let builder = FmtSubscriber::builder() + .with_env_filter(format!("asb={},swap={}", level, level)) .with_writer(std::io::stderr) .with_ansi(is_terminal) - .finish(); + .with_target(false); + + if !is_terminal { + builder.without_time().init(); + } else { + builder.init(); + } - subscriber::set_global_default(subscriber)?; - info!("Initialized tracing with level: {}", level); + tracing::info!("Initialized tracing with level: {}", level); Ok(()) }