From b8df4a3145b5fb257b731cca09fde15aa33a1c7d Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 26 Feb 2021 16:22:24 +1100 Subject: [PATCH] Inline tracing configuration for swap_cli This allows us to configure the presentation separately from the ASB. --- swap/src/bin/swap_cli.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/swap/src/bin/swap_cli.rs b/swap/src/bin/swap_cli.rs index c2a9ed4c..f266460a 100644 --- a/swap/src/bin/swap_cli.rs +++ b/swap/src/bin/swap_cli.rs @@ -34,10 +34,9 @@ use swap::{ bob::{cancel::CancelError, Builder}, }, seed::Seed, - trace::init_tracing, }; -use tracing::{debug, error, info, warn}; -use tracing_subscriber::filter::LevelFilter; +use tracing::{debug, error, info, warn, Level}; +use tracing_subscriber::FmtSubscriber; use uuid::Uuid; #[macro_use] @@ -47,7 +46,15 @@ const MONERO_BLOCKCHAIN_MONITORING_WALLET_NAME: &str = "swap-tool-blockchain-mon #[tokio::main] async fn main() -> Result<()> { - init_tracing(LevelFilter::DEBUG).expect("initialize tracing"); + let is_terminal = atty::is(atty::Stream::Stderr); + let subscriber = FmtSubscriber::builder() + .with_env_filter(format!("swap={}", Level::DEBUG)) + .with_writer(std::io::stderr) + .with_ansi(is_terminal) + .with_target(false) + .finish(); + + tracing::subscriber::set_global_default(subscriber)?; let opt = Arguments::from_args();