Logger init for tests

This commit is contained in:
Ignotus Peverell 2017-10-22 07:09:40 +00:00
parent 6c18451a2b
commit f12559f53b
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
2 changed files with 13 additions and 1 deletions

View file

@ -35,7 +35,7 @@ extern crate serde_derive;
// Logging related // Logging related
pub mod logger; pub mod logger;
pub use logger::{LOGGER, init_logger}; pub use logger::{LOGGER, init_logger, init_test_logger};
pub mod types; pub mod types;
pub use types::LoggingConfig; pub use types::LoggingConfig;

View file

@ -89,3 +89,15 @@ pub fn init_logger(config: Option<LoggingConfig>) {
*was_init_ref = true; *was_init_ref = true;
} }
} }
/// Initializes the logger for unit and integration tests
pub fn init_test_logger() {
let mut was_init_ref = WAS_INIT.lock().unwrap();
if was_init_ref {
return;
}
let mut config_ref = LOGGING_CONFIG.lock().unwrap();
*config_ref = LoggingConfig::default();
*was_init_ref = true;
}