From 1414ec68e420d476d92252b103b2b6a5cd7776b8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 7 Mar 2022 15:22:11 +0100 Subject: [PATCH] Set default log level to WARN --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 8b89d41cd..43230e146 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,8 +36,16 @@ use crate::{ }; fn main() -> anyhow::Result<()> { + // Respect `RUST_LOG`. If that's not defined or erroneous, log warnings and + // above. + // + // It would be better to fail, if `RUST_LOG` is erroneous, but I don't know + // how to distinguish between that and the "not defined" case. tracing_subscriber::fmt() - .with_env_filter(EnvFilter::from_default_env()) + .with_env_filter( + EnvFilter::try_from_default_env() + .unwrap_or_else(|_| EnvFilter::new("WARN")), + ) .event_format(format().pretty()) .init();