feat: add flag for displaying log target (#469)

This commit is contained in:
Bjerg
2022-12-15 17:08:29 +01:00
committed by GitHub
parent 6e577c6e5f
commit c10bdb5830

View File

@ -38,8 +38,11 @@ pub mod reth_tracing {
}
/// Build subscriber
// TODO: JSON/systemd support
pub fn build_subscriber(mods: TracingMode) -> impl Subscriber {
let nocolor = std::env::var("RUST_LOG_STYLE").map(|val| val == "never").unwrap_or(false);
// TODO: Auto-detect
let no_color = std::env::var("RUST_LOG_STYLE").map(|val| val == "never").unwrap_or(false);
let with_target = std::env::var("RUST_LOG_TARGET").map(|val| val != "0").unwrap_or(false);
// Take env over config
let filter = if std::env::var(EnvFilter::DEFAULT_ENV).unwrap_or_default().is_empty() {
@ -49,7 +52,7 @@ pub mod reth_tracing {
};
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().with_ansi(!nocolor).with_target(false))
.with(tracing_subscriber::fmt::layer().with_ansi(!no_color).with_target(with_target))
.with(filter)
}
}