feat(bin): do not show target on INFO level (#6498)

This commit is contained in:
Alexey Shekhirin
2024-02-08 22:36:34 +00:00
committed by GitHub
parent 5ab57bd81a
commit e9f6f7e9de

View File

@ -48,7 +48,14 @@ impl LogFormat {
} else {
false
};
let target = std::env::var("RUST_LOG_TARGET").map(|val| val != "0").unwrap_or(true);
let target = std::env::var("RUST_LOG_TARGET")
// `RUST_LOG_TARGET` always overrides default behaviour
.map(|val| val != "0")
.unwrap_or(
// If `RUST_LOG_TARGET` is not set, show target in logs only if the max enabled
// level is higher than INFO (DEBUG, TRACE)
filter.max_level_hint().map_or(true, |max_level| max_level > tracing::Level::INFO),
);
match self {
LogFormat::Json => {