From ac4bc4b16c065994dc9d1a7a428de5eb21c76aad Mon Sep 17 00:00:00 2001 From: mendess Date: Sun, 15 Oct 2023 20:17:55 +0100 Subject: [PATCH] [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. --- swhks/src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/swhks/src/main.rs b/swhks/src/main.rs index e9c4f71..77d0911 100644 --- a/swhks/src/main.rs +++ b/swhks/src/main.rs @@ -16,8 +16,6 @@ use std::{ use sysinfo::{ProcessExt, System, SystemExt}; fn main() -> std::io::Result<()> { - env::set_var("RUST_LOG", "swhks=warn"); - let app = clap::Command::new("swhks") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) @@ -30,11 +28,13 @@ fn main() -> std::io::Result<()> { )); let args = app.get_matches(); if args.is_present("debug") { - env::set_var("RUST_LOG", "swhks=trace"); + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("swhks=trace")) + .init(); + } else { + env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("swhks=warn")) + .init(); } - env_logger::init(); - log::trace!("Setting process umask."); umask(Mode::S_IWGRP | Mode::S_IWOTH);