Add error for invalid log config

Log config falls back to "warn"
This commit is contained in:
exin 2022-06-25 14:30:20 -05:00 committed by Timo Kösters
parent 9c922db14b
commit 3a40bf8ae0
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4

View file

@ -110,9 +110,13 @@ async fn main() {
start.await;
} else {
let fmt_layer = tracing_subscriber::fmt::Layer::new();
let filter_layer = EnvFilter::try_new(&config.log)
.or_else(|_| EnvFilter::try_new("info"))
.unwrap();
let filter_layer = match EnvFilter::try_new(&config.log) {
Ok(s) => s,
Err(e) => {
eprintln!("It looks like your log config is invalid. The following error occurred: {}", e);
EnvFilter::try_new("warn").unwrap()
},
};
let subscriber = registry.with(filter_layer).with(fmt_layer);
tracing::subscriber::set_global_default(subscriber).unwrap();