Skip to content

Commit 30f25b5

Browse files
mendessShinyzenith
authored andcommitted
[fix] don't override global RUST_LOG variable
Overriding the RUST_LOG variable means it propagates to rust programs spawned by swhks, directly and indirectly.
1 parent 1116772 commit 30f25b5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

swhks/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use std::{
1616
use sysinfo::{ProcessExt, System, SystemExt};
1717

1818
fn main() -> std::io::Result<()> {
19-
env::set_var("RUST_LOG", "swhks=warn");
20-
2119
let app = clap::Command::new("swhks")
2220
.version(env!("CARGO_PKG_VERSION"))
2321
.author(env!("CARGO_PKG_AUTHORS"))
@@ -30,11 +28,13 @@ fn main() -> std::io::Result<()> {
3028
));
3129
let args = app.get_matches();
3230
if args.is_present("debug") {
33-
env::set_var("RUST_LOG", "swhks=trace");
31+
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("swhks=trace"))
32+
.init();
33+
} else {
34+
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("swhks=warn"))
35+
.init();
3436
}
3537

36-
env_logger::init();
37-
3838
log::trace!("Setting process umask.");
3939
umask(Mode::S_IWGRP | Mode::S_IWOTH);
4040

0 commit comments

Comments
 (0)