From f12559f53be487cef74df013008aa8a1ed6b750d Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Sun, 22 Oct 2017 07:09:40 +0000 Subject: [PATCH] Logger init for tests --- util/src/lib.rs | 2 +- util/src/logger.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/util/src/lib.rs b/util/src/lib.rs index 6b078ac77..e2e7ace6e 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -35,7 +35,7 @@ extern crate serde_derive; // Logging related pub mod logger; -pub use logger::{LOGGER, init_logger}; +pub use logger::{LOGGER, init_logger, init_test_logger}; pub mod types; pub use types::LoggingConfig; diff --git a/util/src/logger.rs b/util/src/logger.rs index 1a38d1739..51d2764b5 100644 --- a/util/src/logger.rs +++ b/util/src/logger.rs @@ -89,3 +89,15 @@ pub fn init_logger(config: Option) { *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; +} +