diff --git a/src/bin/main/mod.rs b/src/bin/main/mod.rs index 8306d32..d71d98e 100644 --- a/src/bin/main/mod.rs +++ b/src/bin/main/mod.rs @@ -47,6 +47,7 @@ pub fn main() { // set up our logger to use the given verbosity env_logger::Builder::new() .filter_module("libpt", cli.verbose.log_level_filter()) + .format_target(false) .init(); } else { diff --git a/src/logger/mod.rs b/src/logger/mod.rs index 4032b64..e208be4 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -82,7 +82,11 @@ impl Logger { /// ## initializes the logger to log to a target /// /// Will enable the logger to be used. - pub fn init_specialized(test: bool, color: bool, target: Target) { + pub fn init_specialized(show_module: bool, test: bool, color: bool, target: Option) { + let target = match target { + Some(t) => t, + None => Target::Stdout, + }; // only init if no init has been performed yet if INITIALIZED.load(Ordering::Relaxed) { eprintln!("trying to reinitialize the logger, ignoring"); @@ -97,6 +101,7 @@ impl Logger { } else { WriteStyle::Never }) + .format_target(show_module) .try_init(); if res.is_err() { eprintln!("could not init logger: {}", res.unwrap_err()); @@ -155,13 +160,13 @@ impl Logger { #[pyo3(name = "init")] #[staticmethod] pub fn py_init() { - Self::init() + Self::init_specialized(false, false, true, None) } /// ## Python version of [`init_specialized()`](Logger::init_specialized) #[pyo3(name = "init_specialized")] #[staticmethod] pub fn py_init_specialized(color: bool) { - Self::init_specialized(false, color, Target::Stdout) + Self::init_specialized(false, false, color, None) } /// ## Python version of [`error()`](Logger::error) #[pyo3(name = "error")] diff --git a/tests/test_logger_struct.rs b/tests/test_logger_struct.rs index 6ca2746..410af53 100644 --- a/tests/test_logger_struct.rs +++ b/tests/test_logger_struct.rs @@ -14,7 +14,7 @@ use regex::Regex; fn setup() { // we don't want to log messages during our tests! std::env::set_var(LOGGER_ENV_KEY, "Trace"); - Logger::init_specialized(false, false, env_logger::Target::Stdout); + Logger::init_specialized(true, false, false, None); println!() }