diff --git a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs index 88d9a79db878784ffc0b29c62a62b1287b691abe..06ceb61018a662a085a65b351eb98e972393c6b3 100644 --- a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs +++ b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs @@ -28,20 +28,12 @@ use durs_ws2p_protocol::controller::{WS2PControllerEvent, WebsocketActionOrder}; use durs_ws2p_protocol::orchestrator::OrchestratorMsg; use durs_ws2p_protocol::MySelfWs2pNode; use std::sync::mpsc; -use std::sync::Once; use std::thread; use std::time::Duration; static PORT: &'static u16 = &10899; -static SETUP: Once = Once::new(); static TIMEOUT_IN_MS: &'static u64 = &20_000; -fn setup() { - SETUP.call_once(|| { - durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]); - }); -} - pub fn currency() -> CurrencyName { CurrencyName(String::from("g1")) } @@ -82,7 +74,7 @@ fn client_node() -> MySelfWs2pNode { #[test] #[cfg(unix)] fn test_connection_negociation_denial() { - setup(); + durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]); // ===== initialization ===== // client and server are initialized and launched in separate threads @@ -159,7 +151,7 @@ fn test_connection_negociation_denial() { #[test] #[cfg(unix)] fn test_connection_negociation_success() { - setup(); + durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]); // ===== initialization ===== // client and server are initialized and launched in separate threads diff --git a/lib/tests-tools/common-tests-tools/src/logger.rs b/lib/tests-tools/common-tests-tools/src/logger.rs index 7eadbd24e633848b2c084119e4ba7042b790fc99..ced8980baa7c2822dc54c3cf5159a6a32ecabea1 100644 --- a/lib/tests-tools/common-tests-tools/src/logger.rs +++ b/lib/tests-tools/common-tests-tools/src/logger.rs @@ -17,9 +17,18 @@ use fern::colors::{Color, ColoredLevelConfig}; use log::LevelFilter; +use std::sync::Once; + +static ONCE: Once = Once::new(); /// Initialize stdout logger pub fn init_logger_stdout(off_targets: Vec<&'static str>) { + ONCE.call_once(|| { + init_logger_stdout_(off_targets); + }); +} + +fn init_logger_stdout_(off_targets: Vec<&'static str>) { let colors = match std::env::var("DURS_TESTS_LOG_COLOR") .unwrap_or_else(|_| String::from("no")) .as_str()