feat: update logging configuration to use LOG_LEVEL environment variable instead of debug feature flag

This commit is contained in:
Nikita Galaiko 2023-11-20 09:29:45 +01:00 committed by GitButler
parent 6abf22089b
commit 383d5a3bb5
3 changed files with 7 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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(