cli: default RUST_LOG if it's not set
This commit is contained in:
parent
74c2eaf66d
commit
470fe05b76
1 changed files with 9 additions and 1 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -2,6 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: EUPL-1.1
|
||||
|
||||
use std::env;
|
||||
use std::io::{self, IsTerminal};
|
||||
use std::process::ExitCode;
|
||||
use std::{error::Error as StdError, sync::Arc};
|
||||
|
|
@ -12,6 +13,13 @@ use tracing_subscriber::util::SubscriberInitExt;
|
|||
use tracing_subscriber::{EnvFilter, layer::SubscriberExt};
|
||||
|
||||
fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
|
||||
// Default RUST_LOG to warn if it's not specified.
|
||||
if let None = env::var_os("RUST_LOG") {
|
||||
unsafe {
|
||||
env::set_var("RUST_LOG", "warn");
|
||||
}
|
||||
}
|
||||
|
||||
let args = Arc::new(dynix::Args::parse());
|
||||
|
||||
let success = dynix::_CLI_ENABLE_COLOR.set(match args.color {
|
||||
|
|
@ -47,6 +55,6 @@ fn main() -> ExitCode {
|
|||
Err(e) => {
|
||||
eprintln!("dynix: error: {}", e);
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue