From 383d5a3bb58925823c08843ba27bdd7c9aa4069c Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 20 Nov 2023 09:29:45 +0100 Subject: [PATCH] feat: update logging configuration to use `LOG_LEVEL` environment variable instead of `debug` feature flag --- README.md | 4 ++-- packages/tauri/Cargo.toml | 2 -- packages/tauri/src/logs.rs | 10 +++++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b3076f973..3829480bf 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ Now you should be able to run the app in development mode: $ pnpm tauri dev ``` -By default it will not print debug logs to console. If you want debug logs, use `debug` feature: +By default it will not print debug logs to console. If you want debug logs, set `LOG_LEVEL` environment variable: ```bash -$ pnpm tauri dev --features debug +$ LOG_LEVEL=debug pnpm tauri dev ``` ### Lint & format diff --git a/packages/tauri/Cargo.toml b/packages/tauri/Cargo.toml index 7455aaab1..132a7949a 100644 --- a/packages/tauri/Cargo.toml +++ b/packages/tauri/Cargo.toml @@ -78,8 +78,6 @@ zip = "0.6.5" # by default Tauri runs in production mode # when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL default = ["custom-protocol"] -# enabled debug logging -debug = [] # this feature enables devtools devtools = ["tauri/devtools"] # this feature is used used for production builds where `devPath` points to the filesystem diff --git a/packages/tauri/src/logs.rs b/packages/tauri/src/logs.rs index 0c70590cc..33fecf2e7 100644 --- a/packages/tauri/src/logs.rs +++ b/packages/tauri/src/logs.rs @@ -22,11 +22,11 @@ pub fn init(app_handle: &AppHandle) { .with_target(false) .compact(); - let log_level_filter = if cfg!(feature = "debug") { - LevelFilter::DEBUG - } else { - LevelFilter::INFO - }; + let log_level_filter = std::env::var("LOG_LEVEL") + .unwrap_or("info".to_string()) + .to_lowercase() + .parse() + .unwrap_or(LevelFilter::INFO); let subscriber = tracing_subscriber::registry() .with(