320: Fix env filter for asb r=thomaseizinger a=thomaseizinger

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.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
This commit is contained in:
bors[bot] 2021-03-17 03:51:18 +00:00 committed by GitHub
commit 345bc5b316
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,4 @@
use anyhow::Result; use anyhow::Result;
use tracing::{info, subscriber};
use tracing_log::LogTracer; use tracing_log::LogTracer;
use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::FmtSubscriber; use tracing_subscriber::FmtSubscriber;
@ -13,17 +12,20 @@ pub fn init_tracing(level: LevelFilter) -> Result<()> {
LogTracer::init_with_filter(tracing_log::log::LevelFilter::Info)?; LogTracer::init_with_filter(tracing_log::log::LevelFilter::Info)?;
let is_terminal = atty::is(atty::Stream::Stderr); let is_terminal = atty::is(atty::Stream::Stderr);
let subscriber = FmtSubscriber::builder()
.with_env_filter(format!( let builder = FmtSubscriber::builder()
"swap={},monero_harness={},bitcoin_harness={},http=warn,warp=warn", .with_env_filter(format!("asb={},swap={}", level, level))
level, level, level
))
.with_writer(std::io::stderr) .with_writer(std::io::stderr)
.with_ansi(is_terminal) .with_ansi(is_terminal)
.finish(); .with_target(false);
subscriber::set_global_default(subscriber)?; if !is_terminal {
info!("Initialized tracing with level: {}", level); builder.without_time().init();
} else {
builder.init();
}
tracing::info!("Initialized tracing with level: {}", level);
Ok(()) Ok(())
} }