From 5ebc84c7b98cc648a659ca37fdc0f041057f0ea4 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sat, 5 Nov 2022 17:29:17 +0000 Subject: [PATCH] refactor(logging): consts for default log levels --- src/logging.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/logging.rs b/src/logging.rs index c600c94..b35da3f 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -31,12 +31,15 @@ impl<'a> MakeWriter<'a> for MakeFileWriter { /// The returned `WorkerGuard` must remain in scope /// for the lifetime of the application for logging to file to work. pub fn install_tracing() -> Result { + const DEFAULT_LOG: &str = "info"; + const DEFAULT_FILE_LOG: &str = "warn"; + let fmt_layer = fmt::layer().with_target(true); let filter_layer = - EnvFilter::try_from_env("IRONBAR_LOG").or_else(|_| EnvFilter::try_new("info"))?; + EnvFilter::try_from_env("IRONBAR_LOG").or_else(|_| EnvFilter::try_new(DEFAULT_LOG))?; - let file_filter_layer = - EnvFilter::try_from_env("IRONBAR_FILE_LOG").or_else(|_| EnvFilter::try_new("warn"))?; + let file_filter_layer = EnvFilter::try_from_env("IRONBAR_FILE_LOG") + .or_else(|_| EnvFilter::try_new(DEFAULT_FILE_LOG))?; let log_path = data_dir().unwrap_or(env::current_dir()?).join("ironbar");