Merge pull request #1638 from gitbutlerapp/add-log-level-environment-variable

Add log level environment variable
This commit is contained in:
Nikita Galaiko 2023-11-20 09:40:58 +01:00 committed by GitHub
commit 7f633e59f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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(