mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
fix: init_test_logger update for log4rs (#1921)
This commit is contained in:
parent
f276de1719
commit
d56ef364c4
1 changed files with 39 additions and 0 deletions
|
@ -187,8 +187,47 @@ pub fn init_test_logger() {
|
|||
let mut logger = LoggingConfig::default();
|
||||
logger.log_to_file = false;
|
||||
logger.stdout_log_level = LogLevel::Debug;
|
||||
|
||||
// Save current logging configuration
|
||||
let mut config_ref = LOGGING_CONFIG.lock();
|
||||
*config_ref = logger;
|
||||
|
||||
let level_stdout = convert_log_level(&config_ref.stdout_log_level);
|
||||
let level_minimum = level_stdout; // minimum logging level for Root logger
|
||||
|
||||
// Start logger
|
||||
let stdout = ConsoleAppender::builder()
|
||||
.encoder(Box::new(PatternEncoder::default()))
|
||||
.build();
|
||||
|
||||
let mut root = Root::builder();
|
||||
|
||||
let mut appenders = vec![];
|
||||
|
||||
{
|
||||
let filter = Box::new(ThresholdFilter::new(level_stdout));
|
||||
appenders.push(
|
||||
Appender::builder()
|
||||
.filter(filter)
|
||||
.filter(Box::new(GrinFilter))
|
||||
.build("stdout", Box::new(stdout)),
|
||||
);
|
||||
|
||||
root = root.appender("stdout");
|
||||
}
|
||||
|
||||
let config = Config::builder()
|
||||
.appenders(appenders)
|
||||
.build(root.build(level_minimum))
|
||||
.unwrap();
|
||||
|
||||
let _ = log4rs::init_config(config).unwrap();
|
||||
|
||||
info!(
|
||||
"log4rs is initialized, stdout level: {:?}, min. level: {:?}",
|
||||
level_stdout, level_minimum
|
||||
);
|
||||
|
||||
*was_init_ref = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue