From d3e013a9995fdbeb6a0733ba024fb4d0233ae671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Fri, 6 Jan 2023 12:25:45 +0100 Subject: [PATCH] TestComponent: ensure env_logger is initialized correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is probably not the right place for it but I'm not sure where else to put it. Signed-off-by: Maxime “pep” Buquet --- src/component/test.rs | 2 +- src/main.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/component/test.rs b/src/component/test.rs index c6ebfe2..b368742 100644 --- a/src/component/test.rs +++ b/src/component/test.rs @@ -125,7 +125,7 @@ pub struct Component { impl Component { pub fn new(in_buffer: Vec) -> Self { - env_logger::builder().is_test(true).init(); + let _ = env_logger::builder().is_test(true).try_init(); Component { in_buffer: VecDeque::from( diff --git a/src/main.rs b/src/main.rs index 3ddd25f..69fb3df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,7 @@ async fn main() -> Result<(), Error> { let server = "::1"; let port = 5347u16; + #[cfg(not(test))] env_logger::init(); let mut component = Component::new(jid, passwd, server, port).await.unwrap();