fix: Hide warn-level logs in the zebra-consensus tests

Unless RUST_LOG is set.
This commit is contained in:
teor 2020-07-27 10:29:44 +10:00 committed by Deirdre Connolly
parent a60299d86c
commit 12cbe410f2
1 changed files with 8 additions and 4 deletions

View File

@ -10,10 +10,14 @@ static INIT: Once = Once::new();
pub fn init() {
INIT.call_once(|| {
let fmt_layer = fmt::layer().with_target(false);
// Use the RUST_LOG env var, or 'warn' by default
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("warn"))
.unwrap();
// Use the RUST_LOG env var, or by default:
// - warn for most tests, and
// - for some modules, hide expected warn logs
let filter_layer = EnvFilter::try_from_default_env().unwrap_or_else(|_| {
EnvFilter::try_new("warn")
.unwrap()
.add_directive("zebra_consensus=error".parse().unwrap())
});
tracing_subscriber::registry()
.with(filter_layer)