mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-31 15:20:15 +00:00
c01cccb288
This also formats `log` events more nicely. Instead of ``` Mar 29 09:46:16.775 INFO log: Found message after comparing 82 lines log.target="testcontainers::core::wait_for_message" log.module_path="testcontainers::core::wait_for_message" log.file="/home/thomas/.cargo/registry/src/github.com-1ecc6299db9ec823/testcontainers-0.12.0/src/core/wait_for_message.rs" log.line=35 ``` We now have ``` Mar 29 09:57:15.860 INFO testcontainers::core::wait_for_message: Found message after comparing 81 lines ```
28 lines
674 B
Rust
28 lines
674 B
Rust
use anyhow::Result;
|
|
use tracing_subscriber::filter::LevelFilter;
|
|
use tracing_subscriber::FmtSubscriber;
|
|
|
|
pub fn init_tracing(level: LevelFilter) -> Result<()> {
|
|
if level == LevelFilter::OFF {
|
|
return Ok(());
|
|
}
|
|
|
|
let is_terminal = atty::is(atty::Stream::Stderr);
|
|
|
|
let builder = FmtSubscriber::builder()
|
|
.with_env_filter(format!("asb={},swap={}", level, level))
|
|
.with_writer(std::io::stderr)
|
|
.with_ansi(is_terminal)
|
|
.with_target(false);
|
|
|
|
if !is_terminal {
|
|
builder.without_time().init();
|
|
} else {
|
|
builder.init();
|
|
}
|
|
|
|
tracing::info!("Initialized tracing with level: {}", level);
|
|
|
|
Ok(())
|
|
}
|