generated from PlexSheep/baserepo
dont show module when logging from python
This commit is contained in:
parent
6e7e2c9190
commit
85e0d5e2a7
|
@ -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 {
|
||||
|
|
|
@ -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<Target>) {
|
||||
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")]
|
||||
|
|
|
@ -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!()
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue