From 4f42ce780da20bd2a08c06bf5cbb5d6ad7db031d Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Wed, 17 Apr 2024 18:49:54 +0200 Subject: [PATCH] Fix tracing logging functions (#945) * Add file header * Fix log functions * Remove erroneous code in valgrind CI * Address comments --- ci/valgrind-check/Cargo.toml | 4 +- .../src/pub_sub/bin/z_pub_sub.rs | 5 +- .../src/queryable_get/bin/z_queryable_get.rs | 9 ++-- commons/zenoh-codec/tests/codec.rs | 2 +- commons/zenoh-util/Cargo.toml | 1 + commons/zenoh-util/src/std_only/log.rs | 46 +++++++++++++++++-- commons/zenoh-util/src/std_only/mod.rs | 3 +- examples/examples/z_delete.rs | 2 +- examples/examples/z_forward.rs | 2 +- examples/examples/z_get.rs | 2 +- examples/examples/z_get_liveliness.rs | 2 +- examples/examples/z_info.rs | 2 +- examples/examples/z_liveliness.rs | 2 +- examples/examples/z_ping.rs | 2 +- examples/examples/z_pong.rs | 2 +- examples/examples/z_pub.rs | 2 +- examples/examples/z_pub_shm.rs | 2 +- examples/examples/z_pub_shm_thr.rs | 2 +- examples/examples/z_pub_thr.rs | 2 +- examples/examples/z_pull.rs | 2 +- examples/examples/z_put.rs | 2 +- examples/examples/z_put_float.rs | 2 +- examples/examples/z_queryable.rs | 2 +- examples/examples/z_scout.rs | 2 +- examples/examples/z_storage.rs | 2 +- examples/examples/z_sub.rs | 2 +- examples/examples/z_sub_liveliness.rs | 2 +- examples/examples/z_sub_thr.rs | 2 +- io/zenoh-transport/tests/endpoints.rs | 24 +++++----- .../tests/multicast_compression.rs | 2 +- .../tests/multicast_transport.rs | 2 +- .../tests/transport_whitelist.rs | 6 +-- .../tests/unicast_authenticator.rs | 22 ++++----- .../tests/unicast_compression.rs | 8 ++-- .../tests/unicast_concurrent.rs | 6 +-- .../tests/unicast_defragmentation.rs | 6 +-- .../tests/unicast_intermittent.rs | 14 +++--- io/zenoh-transport/tests/unicast_multilink.rs | 14 +++--- io/zenoh-transport/tests/unicast_openclose.rs | 30 ++++++------ .../tests/unicast_priorities.rs | 6 +-- io/zenoh-transport/tests/unicast_shm.rs | 12 ++--- .../tests/unicast_simultaneous.rs | 6 +-- io/zenoh-transport/tests/unicast_transport.rs | 38 +++++++-------- plugins/zenoh-plugin-example/src/lib.rs | 2 +- .../zenoh-plugin-rest/examples/z_serve_sse.rs | 2 +- plugins/zenoh-plugin-rest/src/lib.rs | 4 +- .../zenoh-plugin-storage-manager/src/lib.rs | 4 +- zenoh-ext/examples/examples/z_member.rs | 2 +- zenoh-ext/examples/examples/z_pub_cache.rs | 2 +- zenoh-ext/examples/examples/z_query_sub.rs | 2 +- zenoh-ext/examples/examples/z_view_size.rs | 2 +- zenoh/tests/acl.rs | 2 +- zenoh/tests/interceptors.rs | 6 +-- zenoh/tests/routing.rs | 8 ++-- zenoh/tests/session.rs | 4 +- zenoh/tests/unicity.rs | 4 +- 56 files changed, 193 insertions(+), 159 deletions(-) diff --git a/ci/valgrind-check/Cargo.toml b/ci/valgrind-check/Cargo.toml index 72e7f6473a..067e5e53ee 100644 --- a/ci/valgrind-check/Cargo.toml +++ b/ci/valgrind-check/Cargo.toml @@ -23,11 +23,11 @@ description = "Internal crate for zenoh." [dependencies] tokio = { version = "1.35.1", features = ["rt-multi-thread", "time", "io-std"] } -tracing-subscriber = {version = "0.3", features = ["json", "env-filter"]} +tracing-subscriber = { version = "0.3", features = ["json", "env-filter"] } futures = "0.3.25" zenoh = { path = "../../zenoh/" } zenoh-runtime = { path = "../../commons/zenoh-runtime/" } -zenoh-util = { path = "../../commons/zenoh-util/" } +zenoh-util = { path = "../../commons/zenoh-util/", features = ["test"] } [[bin]] name = "pub_sub" diff --git a/ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs b/ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs index a5fabcc705..45b36aa5e7 100644 --- a/ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs +++ b/ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs @@ -14,11 +14,10 @@ use std::time::Duration; use zenoh::config::Config; use zenoh::prelude::r#async::*; -use zenoh_util::init_log; + #[tokio::main] async fn main() { - - init_log(); + zenoh_util::init_log_test(); let _z = zenoh_runtime::ZRuntimePoolGuard; diff --git a/ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs b/ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs index 892f76e6d6..edd8000bf1 100644 --- a/ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs +++ b/ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs @@ -15,11 +15,10 @@ use std::convert::TryFrom; use std::time::Duration; use zenoh::config::Config; use zenoh::prelude::r#async::*; -use zenoh_util::init_log; #[tokio::main] async fn main() { - init_log(); + zenoh_util::init_log_test(); let _z = zenoh_runtime::ZRuntimePoolGuard; @@ -36,9 +35,9 @@ async fn main() { queryable_key_expr.clone(), query.value().unwrap().clone(), )); - zenoh_runtime::ZRuntime::Application.block_in_place( - async move { query.reply(reply).res().await.unwrap(); } - ); + zenoh_runtime::ZRuntime::Application.block_in_place(async move { + query.reply(reply).res().await.unwrap(); + }); }) .complete(true) .res() diff --git a/commons/zenoh-codec/tests/codec.rs b/commons/zenoh-codec/tests/codec.rs index 1e4ea22491..3c1a6a821b 100644 --- a/commons/zenoh-codec/tests/codec.rs +++ b/commons/zenoh-codec/tests/codec.rs @@ -342,7 +342,7 @@ fn codec_shm_info() { // Common #[test] fn codec_extension() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); macro_rules! run_extension_single { ($ext:ty, $buff:expr) => { diff --git a/commons/zenoh-util/Cargo.toml b/commons/zenoh-util/Cargo.toml index 909ba12f6a..48bbb17d04 100644 --- a/commons/zenoh-util/Cargo.toml +++ b/commons/zenoh-util/Cargo.toml @@ -33,6 +33,7 @@ maintenance = { status = "actively-developed" } [features] std = [] +test = [] default = ["std"] [dependencies] diff --git a/commons/zenoh-util/src/std_only/log.rs b/commons/zenoh-util/src/std_only/log.rs index 2587fa877f..07d66d9233 100644 --- a/commons/zenoh-util/src/std_only/log.rs +++ b/commons/zenoh-util/src/std_only/log.rs @@ -1,16 +1,49 @@ +// +// Copyright (c) 2024 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, +// use tracing_subscriber::EnvFilter; /// This is an utility function to enable the tracing formatting subscriber from -/// the `RUST_LOG` environment variable. +/// the `RUST_LOG` environment variable. If `RUST_LOG` is not set, then logging is not enabled. /// /// # Safety /// Calling this function initializes a `lazy_static` in the `tracing` crate /// such static is not deallocated prior to process existing, thus tools such as `valgrind` /// will report a memory leak. /// Refer to this issue: https://github.com/tokio-rs/tracing/issues/2069 -pub fn init_log_from_env() { - let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("z=info")); +pub fn try_init_log_from_env() { + if let Ok(env_filter) = EnvFilter::try_from_default_env() { + init_env_filter(env_filter); + } +} + +/// This is an utility function to enable the tracing formatting subscriber from +/// the environment variable. If `RUST_LOG` is not set, then fallback directives are used. +/// +/// # Safety +/// Calling this function initializes a `lazy_static` in the `tracing` crate +/// such static is not deallocated prior to process existing, thus tools such as `valgrind` +/// will report a memory leak. +/// Refer to this issue: https://github.com/tokio-rs/tracing/issues/2069 +pub fn init_log_from_env_or(fallback: S) +where + S: AsRef, +{ + let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(fallback)); + init_env_filter(env_filter); +} +fn init_env_filter(env_filter: EnvFilter) { let subscriber = tracing_subscriber::fmt() .with_env_filter(env_filter) .with_thread_ids(true) @@ -22,8 +55,11 @@ pub fn init_log_from_env() { let _ = tracing::subscriber::set_global_default(subscriber); } -/// This is an utility function to enables the default tracing subscriber with INFO level -pub fn init_log() { +#[cfg(feature = "test")] +// Used to verify memory leaks for valgrind CI. +// `EnvFilter` internally uses a static reference that is not cleaned up yielding to false positive in valgrind. +// This function enables logging without calling `EnvFilter` for env configuration. +pub fn init_log_test() { let subscriber = tracing_subscriber::fmt() .with_max_level(tracing::Level::INFO) .with_thread_ids(true) diff --git a/commons/zenoh-util/src/std_only/mod.rs b/commons/zenoh-util/src/std_only/mod.rs index 3ccd2152a0..1cb406374c 100644 --- a/commons/zenoh-util/src/std_only/mod.rs +++ b/commons/zenoh-util/src/std_only/mod.rs @@ -6,8 +6,7 @@ pub use lib_loader::*; pub mod timer; pub use timer::*; pub mod log; -pub use log::init_log; -pub use log::init_log_from_env; +pub use log::*; /// The "ZENOH_HOME" environement variable name pub const ZENOH_HOME_ENV_VAR: &str = "ZENOH_HOME"; diff --git a/examples/examples/z_delete.rs b/examples/examples/z_delete.rs index ad87227fcd..046ac29ce9 100644 --- a/examples/examples/z_delete.rs +++ b/examples/examples/z_delete.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr) = parse_args(); diff --git a/examples/examples/z_forward.rs b/examples/examples/z_forward.rs index 9541511e84..0c7d90dc7a 100644 --- a/examples/examples/z_forward.rs +++ b/examples/examples/z_forward.rs @@ -20,7 +20,7 @@ use zenoh_ext::SubscriberForward; #[tokio::main] async fn main() { // Initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, forward) = parse_args(); diff --git a/examples/examples/z_get.rs b/examples/examples/z_get.rs index a71cc7fed0..234642503d 100644 --- a/examples/examples/z_get.rs +++ b/examples/examples/z_get.rs @@ -21,7 +21,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, selector, value, target, timeout) = parse_args(); diff --git a/examples/examples/z_get_liveliness.rs b/examples/examples/z_get_liveliness.rs index cbeea17164..7e808f5675 100644 --- a/examples/examples/z_get_liveliness.rs +++ b/examples/examples/z_get_liveliness.rs @@ -21,7 +21,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, timeout) = parse_args(); diff --git a/examples/examples/z_info.rs b/examples/examples/z_info.rs index 9525a7abf1..f28b9ad72c 100644 --- a/examples/examples/z_info.rs +++ b/examples/examples/z_info.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let config = parse_args(); diff --git a/examples/examples/z_liveliness.rs b/examples/examples/z_liveliness.rs index f82d62e8bd..9e17ba3965 100644 --- a/examples/examples/z_liveliness.rs +++ b/examples/examples/z_liveliness.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // Initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr) = parse_args(); diff --git a/examples/examples/z_ping.rs b/examples/examples/z_ping.rs index 404272f1fa..8d0c13f0ef 100644 --- a/examples/examples/z_ping.rs +++ b/examples/examples/z_ping.rs @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs; fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, warmup, size, n) = parse_args(); let session = zenoh::open(config).res().unwrap(); diff --git a/examples/examples/z_pong.rs b/examples/examples/z_pong.rs index 865734abe6..f57b5d9685 100644 --- a/examples/examples/z_pong.rs +++ b/examples/examples/z_pong.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let config = parse_args(); diff --git a/examples/examples/z_pub.rs b/examples/examples/z_pub.rs index 39f788272e..5de92231a1 100644 --- a/examples/examples/z_pub.rs +++ b/examples/examples/z_pub.rs @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // Initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, value, attachment) = parse_args(); diff --git a/examples/examples/z_pub_shm.rs b/examples/examples/z_pub_shm.rs index fa72714741..542cff3b6d 100644 --- a/examples/examples/z_pub_shm.rs +++ b/examples/examples/z_pub_shm.rs @@ -24,7 +24,7 @@ const K: u32 = 3; #[tokio::main] async fn main() -> Result<(), zenoh::Error> { // Initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (mut config, path, value) = parse_args(); diff --git a/examples/examples/z_pub_shm_thr.rs b/examples/examples/z_pub_shm_thr.rs index 8917eda74d..437f6b2d6d 100644 --- a/examples/examples/z_pub_shm_thr.rs +++ b/examples/examples/z_pub_shm_thr.rs @@ -21,7 +21,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (mut config, sm_size, size) = parse_args(); // A probing procedure for shared memory is performed upon session opening. To enable `z_pub_shm_thr` to operate diff --git a/examples/examples/z_pub_thr.rs b/examples/examples/z_pub_thr.rs index 43464f709a..737e7f197f 100644 --- a/examples/examples/z_pub_thr.rs +++ b/examples/examples/z_pub_thr.rs @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs; fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let args = Args::parse(); let mut prio = Priority::default(); diff --git a/examples/examples/z_pull.rs b/examples/examples/z_pull.rs index 855502cea9..f397c249ff 100644 --- a/examples/examples/z_pull.rs +++ b/examples/examples/z_pull.rs @@ -20,7 +20,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr) = parse_args(); diff --git a/examples/examples/z_put.rs b/examples/examples/z_put.rs index eeab4647d8..141f4190c8 100644 --- a/examples/examples/z_put.rs +++ b/examples/examples/z_put.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, value) = parse_args(); diff --git a/examples/examples/z_put_float.rs b/examples/examples/z_put_float.rs index ff34a7a4ba..83a362bac0 100644 --- a/examples/examples/z_put_float.rs +++ b/examples/examples/z_put_float.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, value) = parse_args(); diff --git a/examples/examples/z_queryable.rs b/examples/examples/z_queryable.rs index a83187ea24..397c76297e 100644 --- a/examples/examples/z_queryable.rs +++ b/examples/examples/z_queryable.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, value, complete) = parse_args(); diff --git a/examples/examples/z_scout.rs b/examples/examples/z_scout.rs index 2f4e0bf7d1..b960b4698a 100644 --- a/examples/examples/z_scout.rs +++ b/examples/examples/z_scout.rs @@ -18,7 +18,7 @@ use zenoh::scouting::WhatAmI; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); println!("Scouting..."); let receiver = zenoh::scout(WhatAmI::Peer | WhatAmI::Router, Config::default()) diff --git a/examples/examples/z_storage.rs b/examples/examples/z_storage.rs index f85a11cdae..c5b19c2ab1 100644 --- a/examples/examples/z_storage.rs +++ b/examples/examples/z_storage.rs @@ -23,7 +23,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, complete) = parse_args(); diff --git a/examples/examples/z_sub.rs b/examples/examples/z_sub.rs index 291030062c..d043fb892e 100644 --- a/examples/examples/z_sub.rs +++ b/examples/examples/z_sub.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // Initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (mut config, key_expr) = parse_args(); diff --git a/examples/examples/z_sub_liveliness.rs b/examples/examples/z_sub_liveliness.rs index b0c9965749..c05311a09c 100644 --- a/examples/examples/z_sub_liveliness.rs +++ b/examples/examples/z_sub_liveliness.rs @@ -19,7 +19,7 @@ use zenoh_examples::CommonArgs; #[tokio::main] async fn main() { // Initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr) = parse_args(); diff --git a/examples/examples/z_sub_thr.rs b/examples/examples/z_sub_thr.rs index e93893a49f..2a3511b0bf 100644 --- a/examples/examples/z_sub_thr.rs +++ b/examples/examples/z_sub_thr.rs @@ -69,7 +69,7 @@ impl Drop for Stats { fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (mut config, m, n) = parse_args(); diff --git a/io/zenoh-transport/tests/endpoints.rs b/io/zenoh-transport/tests/endpoints.rs index ca24aa8f60..6269f78cb9 100644 --- a/io/zenoh-transport/tests/endpoints.rs +++ b/io/zenoh-transport/tests/endpoints.rs @@ -99,7 +99,7 @@ async fn run(endpoints: &[EndPoint]) { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_tcp() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ format!("tcp/127.0.0.1:{}", 7000).parse().unwrap(), @@ -112,7 +112,7 @@ async fn endpoint_tcp() { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_udp() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ format!("udp/127.0.0.1:{}", 7010).parse().unwrap(), @@ -125,7 +125,7 @@ async fn endpoint_udp() { #[cfg(all(feature = "transport_unixsock-stream", target_family = "unix"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_unix() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Remove the files if they still exists let f1 = "zenoh-test-unix-socket-0.sock"; let f2 = "zenoh-test-unix-socket-1.sock"; @@ -146,7 +146,7 @@ async fn endpoint_unix() { #[cfg(feature = "transport_ws")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_ws() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ format!("ws/127.0.0.1:{}", 7020).parse().unwrap(), @@ -159,7 +159,7 @@ async fn endpoint_ws() { #[cfg(feature = "transport_unixpipe")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_unixpipe() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ "unixpipe/endpoint_unixpipe".parse().unwrap(), @@ -173,7 +173,7 @@ async fn endpoint_unixpipe() { #[cfg(all(feature = "transport_tcp", feature = "transport_udp"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_tcp_udp() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ format!("tcp/127.0.0.1:{}", 7030).parse().unwrap(), @@ -192,7 +192,7 @@ async fn endpoint_tcp_udp() { ))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_tcp_udp_unix() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Remove the file if it still exists let f1 = "zenoh-test-unix-socket-2.sock"; let _ = std::fs::remove_file(f1); @@ -216,7 +216,7 @@ async fn endpoint_tcp_udp_unix() { ))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_tcp_unix() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Remove the file if it still exists let f1 = "zenoh-test-unix-socket-3.sock"; let _ = std::fs::remove_file(f1); @@ -238,7 +238,7 @@ async fn endpoint_tcp_unix() { ))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_udp_unix() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Remove the file if it still exists let f1 = "zenoh-test-unix-socket-4.sock"; let _ = std::fs::remove_file(f1); // Define the locators @@ -257,7 +257,7 @@ async fn endpoint_udp_unix() { async fn endpoint_tls() { use zenoh_link::tls::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // NOTE: this an auto-generated pair of certificate and key. // The target domain is localhost, so it has no real @@ -336,7 +336,7 @@ AXVFFIgCSluyrolaD6CWD9MqOex4YOfJR2bNxI7lFvuK4AwjyUJzT1U1HXib17mM async fn endpoint_quic() { use zenoh_link::quic::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // NOTE: this an auto-generated pair of certificate and key. // The target domain is localhost, so it has no real @@ -412,7 +412,7 @@ AXVFFIgCSluyrolaD6CWD9MqOex4YOfJR2bNxI7lFvuK4AwjyUJzT1U1HXib17mM #[cfg(all(feature = "transport_vsock", target_os = "linux"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn endpoint_vsock() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ "vsock/-1:1234".parse().unwrap(), diff --git a/io/zenoh-transport/tests/multicast_compression.rs b/io/zenoh-transport/tests/multicast_compression.rs index e2ed01469c..e046c96958 100644 --- a/io/zenoh-transport/tests/multicast_compression.rs +++ b/io/zenoh-transport/tests/multicast_compression.rs @@ -331,7 +331,7 @@ mod tests { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_multicast_compression_udp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![ diff --git a/io/zenoh-transport/tests/multicast_transport.rs b/io/zenoh-transport/tests/multicast_transport.rs index 9f0ecdff8d..dae52742ee 100644 --- a/io/zenoh-transport/tests/multicast_transport.rs +++ b/io/zenoh-transport/tests/multicast_transport.rs @@ -327,7 +327,7 @@ mod tests { #[cfg(all(feature = "transport_compression", feature = "transport_udp"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_multicast_udp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![ diff --git a/io/zenoh-transport/tests/transport_whitelist.rs b/io/zenoh-transport/tests/transport_whitelist.rs index 399a9dea45..a859a1c0c9 100644 --- a/io/zenoh-transport/tests/transport_whitelist.rs +++ b/io/zenoh-transport/tests/transport_whitelist.rs @@ -117,7 +117,7 @@ async fn run(endpoints: &[EndPoint]) { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_whitelist_tcp() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ @@ -132,7 +132,7 @@ async fn transport_whitelist_tcp() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_whitelist_unixpipe() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ @@ -146,7 +146,7 @@ async fn transport_whitelist_unixpipe() { #[cfg(all(feature = "transport_vsock", target_os = "linux"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_whitelist_vsock() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ diff --git a/io/zenoh-transport/tests/unicast_authenticator.rs b/io/zenoh-transport/tests/unicast_authenticator.rs index 8acb604528..a232584cff 100644 --- a/io/zenoh-transport/tests/unicast_authenticator.rs +++ b/io/zenoh-transport/tests/unicast_authenticator.rs @@ -637,7 +637,7 @@ async fn run_with_lowlatency_transport(endpoint: &EndPoint) { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn authenticator_tcp() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 8000).parse().unwrap(); run_with_universal_transport(&endpoint).await; } @@ -645,7 +645,7 @@ async fn authenticator_tcp() { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn authenticator_tcp_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 8100).parse().unwrap(); run_with_lowlatency_transport(&endpoint).await; } @@ -653,7 +653,7 @@ async fn authenticator_tcp_with_lowlatency_transport() { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn authenticator_udp() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("udp/127.0.0.1:{}", 8010).parse().unwrap(); run_with_universal_transport(&endpoint).await; } @@ -661,7 +661,7 @@ async fn authenticator_udp() { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn authenticator_udp_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("udp/127.0.0.1:{}", 8110).parse().unwrap(); run_with_lowlatency_transport(&endpoint).await; } @@ -670,7 +670,7 @@ async fn authenticator_udp_with_lowlatency_transport() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn authenticator_unixpipe() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/authenticator_unixpipe_test".parse().unwrap(); run_with_universal_transport(&endpoint).await; } @@ -679,7 +679,7 @@ async fn authenticator_unixpipe() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn authenticator_unixpipe_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/authenticator_unixpipe_with_lowlatency_transport" .parse() .unwrap(); @@ -690,7 +690,7 @@ async fn authenticator_unixpipe_with_lowlatency_transport() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn authenticator_ws() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 8020).parse().unwrap(); run_with_universal_transport(&endpoint).await; } @@ -699,7 +699,7 @@ async fn authenticator_ws() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn authenticator_ws_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 8120).parse().unwrap(); run_with_lowlatency_transport(&endpoint).await; } @@ -707,7 +707,7 @@ async fn authenticator_ws_with_lowlatency_transport() { #[cfg(all(feature = "transport_unixsock-stream", target_family = "unix"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn authenticator_unix() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let f1 = "zenoh-test-unix-socket-10.sock"; let _ = std::fs::remove_file(f1); let endpoint: EndPoint = format!("unixsock-stream/{f1}").parse().unwrap(); @@ -721,7 +721,7 @@ async fn authenticator_unix() { async fn authenticator_tls() { use zenoh_link::tls::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // NOTE: this an auto-generated pair of certificate and key. // The target domain is localhost, so it has no real @@ -821,7 +821,7 @@ R+IdLiXcyIkg0m9N8I17p0ljCSkbrgGMD3bbePRTfg== async fn authenticator_quic() { use zenoh_link::quic::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // NOTE: this an auto-generated pair of certificate and key. // The target domain is localhost, so it has no real diff --git a/io/zenoh-transport/tests/unicast_compression.rs b/io/zenoh-transport/tests/unicast_compression.rs index e4fbae4862..ab6a9ff414 100644 --- a/io/zenoh-transport/tests/unicast_compression.rs +++ b/io/zenoh-transport/tests/unicast_compression.rs @@ -422,7 +422,7 @@ mod tests { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_compression_tcp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ @@ -447,7 +447,7 @@ mod tests { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_compression_tcp_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![format!("tcp/127.0.0.1:{}", 19100).parse().unwrap()]; @@ -469,7 +469,7 @@ mod tests { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_compression_udp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![ @@ -494,7 +494,7 @@ mod tests { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_compression_udp_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![format!("udp/127.0.0.1:{}", 19110).parse().unwrap()]; diff --git a/io/zenoh-transport/tests/unicast_concurrent.rs b/io/zenoh-transport/tests/unicast_concurrent.rs index 1cbaab75c7..829ae0dea6 100644 --- a/io/zenoh-transport/tests/unicast_concurrent.rs +++ b/io/zenoh-transport/tests/unicast_concurrent.rs @@ -348,7 +348,7 @@ async fn transport_concurrent(endpoint01: Vec, endpoint02: Vec = vec![ format!("tcp/127.0.0.1:{}", 9000).parse().unwrap(), @@ -378,7 +378,7 @@ async fn transport_tcp_concurrent() { #[tokio::test] #[ignore] async fn transport_ws_concurrent() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint01: Vec = vec![ format!("ws/127.0.0.1:{}", 9020).parse().unwrap(), @@ -408,7 +408,7 @@ async fn transport_ws_concurrent() { #[tokio::test] #[ignore] async fn transport_unixpipe_concurrent() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint01: Vec = vec![ "unixpipe/transport_unixpipe_concurrent".parse().unwrap(), diff --git a/io/zenoh-transport/tests/unicast_defragmentation.rs b/io/zenoh-transport/tests/unicast_defragmentation.rs index 9a3b656cdc..f77441b568 100644 --- a/io/zenoh-transport/tests/unicast_defragmentation.rs +++ b/io/zenoh-transport/tests/unicast_defragmentation.rs @@ -131,7 +131,7 @@ async fn run(endpoint: &EndPoint, channel: Channel, msg_size: usize) { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_defragmentation_tcp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 11000).parse().unwrap(); @@ -164,7 +164,7 @@ async fn transport_unicast_defragmentation_tcp_only() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_unicast_defragmentation_ws_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 11010).parse().unwrap(); @@ -197,7 +197,7 @@ async fn transport_unicast_defragmentation_ws_only() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_unicast_defragmentation_unixpipe_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoint: EndPoint = "unixpipe/transport_unicast_defragmentation_unixpipe_only" diff --git a/io/zenoh-transport/tests/unicast_intermittent.rs b/io/zenoh-transport/tests/unicast_intermittent.rs index c076cf5fa7..1eb268770c 100644 --- a/io/zenoh-transport/tests/unicast_intermittent.rs +++ b/io/zenoh-transport/tests/unicast_intermittent.rs @@ -414,7 +414,7 @@ async fn lowlatency_transport_intermittent(endpoint: &EndPoint) { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_tcp_intermittent() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 12000).parse().unwrap(); universal_transport_intermittent(&endpoint).await; } @@ -422,7 +422,7 @@ async fn transport_tcp_intermittent() { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_tcp_intermittent_for_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 12100).parse().unwrap(); lowlatency_transport_intermittent(&endpoint).await; } @@ -431,7 +431,7 @@ async fn transport_tcp_intermittent_for_lowlatency_transport() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_ws_intermittent() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 12010).parse().unwrap(); universal_transport_intermittent(&endpoint).await; } @@ -440,7 +440,7 @@ async fn transport_ws_intermittent() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_ws_intermittent_for_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 12110).parse().unwrap(); lowlatency_transport_intermittent(&endpoint).await; } @@ -449,7 +449,7 @@ async fn transport_ws_intermittent_for_lowlatency_transport() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_unixpipe_intermittent() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/transport_unixpipe_intermittent".parse().unwrap(); universal_transport_intermittent(&endpoint).await; } @@ -458,7 +458,7 @@ async fn transport_unixpipe_intermittent() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_unixpipe_intermittent_for_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/transport_unixpipe_intermittent_for_lowlatency_transport" .parse() .unwrap(); @@ -468,7 +468,7 @@ async fn transport_unixpipe_intermittent_for_lowlatency_transport() { #[cfg(all(feature = "transport_vsock", target_os = "linux"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_vsock_intermittent() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "vsock/VMADDR_CID_LOCAL:17000".parse().unwrap(); universal_transport_intermittent(&endpoint).await; } diff --git a/io/zenoh-transport/tests/unicast_multilink.rs b/io/zenoh-transport/tests/unicast_multilink.rs index c2d188e16a..d69a30ac9d 100644 --- a/io/zenoh-transport/tests/unicast_multilink.rs +++ b/io/zenoh-transport/tests/unicast_multilink.rs @@ -477,7 +477,7 @@ mod tests { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn multilink_tcp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 18000).parse().unwrap(); multilink_transport(&endpoint).await; @@ -486,7 +486,7 @@ mod tests { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn multilink_udp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("udp/127.0.0.1:{}", 18010).parse().unwrap(); multilink_transport(&endpoint).await; @@ -496,7 +496,7 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn multilink_ws_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 18020).parse().unwrap(); multilink_transport(&endpoint).await; @@ -506,7 +506,7 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn multilink_unixpipe_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/multilink_unixpipe_only".parse().unwrap(); multilink_transport(&endpoint).await; @@ -516,7 +516,7 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn multilink_unix_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let f1 = "zenoh-test-unix-socket-9.sock"; let _ = std::fs::remove_file(f1); @@ -531,7 +531,7 @@ mod tests { async fn multilink_tls_only() { use zenoh_link::tls::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // NOTE: this an auto-generated pair of certificate and key. // The target domain is localhost, so it has no real @@ -726,7 +726,7 @@ R+IdLiXcyIkg0m9N8I17p0ljCSkbrgGMD3bbePRTfg== #[cfg(all(feature = "transport_vsock", target_os = "linux"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn multilink_vsock_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "vsock/VMADDR_CID_LOCAL:17000".parse().unwrap(); multilink_transport(&endpoint).await; diff --git a/io/zenoh-transport/tests/unicast_openclose.rs b/io/zenoh-transport/tests/unicast_openclose.rs index 6eec9a4cb1..483e81ade4 100644 --- a/io/zenoh-transport/tests/unicast_openclose.rs +++ b/io/zenoh-transport/tests/unicast_openclose.rs @@ -475,7 +475,7 @@ async fn openclose_lowlatency_transport(endpoint: &EndPoint) { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn openclose_tcp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 13000).parse().unwrap(); openclose_universal_transport(&endpoint).await; } @@ -483,7 +483,7 @@ async fn openclose_tcp_only() { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn openclose_tcp_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 13100).parse().unwrap(); openclose_lowlatency_transport(&endpoint).await; } @@ -491,7 +491,7 @@ async fn openclose_tcp_only_with_lowlatency_transport() { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn openclose_udp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("udp/127.0.0.1:{}", 13010).parse().unwrap(); openclose_universal_transport(&endpoint).await; } @@ -499,7 +499,7 @@ async fn openclose_udp_only() { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn openclose_udp_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("udp/127.0.0.1:{}", 13110).parse().unwrap(); openclose_lowlatency_transport(&endpoint).await; } @@ -508,7 +508,7 @@ async fn openclose_udp_only_with_lowlatency_transport() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn openclose_ws_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 13020).parse().unwrap(); openclose_universal_transport(&endpoint).await; } @@ -517,7 +517,7 @@ async fn openclose_ws_only() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn openclose_ws_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 13120).parse().unwrap(); openclose_lowlatency_transport(&endpoint).await; } @@ -526,7 +526,7 @@ async fn openclose_ws_only_with_lowlatency_transport() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn openclose_unixpipe_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/openclose_unixpipe_only".parse().unwrap(); openclose_universal_transport(&endpoint).await; } @@ -535,7 +535,7 @@ async fn openclose_unixpipe_only() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn openclose_unixpipe_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/openclose_unixpipe_only_with_lowlatency_transport" .parse() .unwrap(); @@ -546,7 +546,7 @@ async fn openclose_unixpipe_only_with_lowlatency_transport() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn openclose_unix_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let f1 = "zenoh-test-unix-socket-9.sock"; let _ = std::fs::remove_file(f1); let endpoint: EndPoint = format!("unixsock-stream/{f1}").parse().unwrap(); @@ -560,7 +560,7 @@ async fn openclose_unix_only() { async fn openclose_tls_only() { use zenoh_link::tls::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // NOTE: this an auto-generated pair of certificate and key. // The target domain is localhost, so it has no real // mapping to any existing domain. The certificate and key @@ -758,7 +758,7 @@ R+IdLiXcyIkg0m9N8I17p0ljCSkbrgGMD3bbePRTfg== async fn openclose_tcp_only_connect_with_interface_restriction() { let addrs = get_ipv4_ipaddrs(None); - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let listen_endpoint: EndPoint = format!("tcp/{}:{}", addrs[0], 13001).parse().unwrap(); @@ -777,7 +777,7 @@ async fn openclose_tcp_only_connect_with_interface_restriction() { async fn openclose_tcp_only_listen_with_interface_restriction() { let addrs = get_ipv4_ipaddrs(None); - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let listen_endpoint: EndPoint = format!("tcp/{}:{}#iface=lo", addrs[0], 13002) .parse() @@ -796,7 +796,7 @@ async fn openclose_tcp_only_listen_with_interface_restriction() { async fn openclose_udp_only_connect_with_interface_restriction() { let addrs = get_ipv4_ipaddrs(None); - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let listen_endpoint: EndPoint = format!("udp/{}:{}", addrs[0], 13003).parse().unwrap(); @@ -815,7 +815,7 @@ async fn openclose_udp_only_connect_with_interface_restriction() { async fn openclose_udp_only_listen_with_interface_restriction() { let addrs = get_ipv4_ipaddrs(None); - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let listen_endpoint: EndPoint = format!("udp/{}:{}#iface=lo", addrs[0], 13004) .parse() .unwrap(); @@ -829,7 +829,7 @@ async fn openclose_udp_only_listen_with_interface_restriction() { #[cfg(all(feature = "transport_vsock", target_os = "linux"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn openclose_vsock() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "vsock/VMADDR_CID_LOCAL:17000".parse().unwrap(); openclose_lowlatency_transport(&endpoint).await; } diff --git a/io/zenoh-transport/tests/unicast_priorities.rs b/io/zenoh-transport/tests/unicast_priorities.rs index 7d2e295a5a..3a594cfea3 100644 --- a/io/zenoh-transport/tests/unicast_priorities.rs +++ b/io/zenoh-transport/tests/unicast_priorities.rs @@ -332,7 +332,7 @@ async fn run(endpoints: &[EndPoint]) { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn priorities_tcp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![format!("tcp/127.0.0.1:{}", 10000).parse().unwrap()]; // Run @@ -343,7 +343,7 @@ async fn priorities_tcp_only() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn conduits_unixpipe_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec!["unixpipe/conduits_unixpipe_only" .to_string() @@ -356,7 +356,7 @@ async fn conduits_unixpipe_only() { #[cfg(feature = "transport_ws")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn priorities_ws_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![format!("ws/127.0.0.1:{}", 10010).parse().unwrap()]; // Run diff --git a/io/zenoh-transport/tests/unicast_shm.rs b/io/zenoh-transport/tests/unicast_shm.rs index e7a4191cc2..d04a54c63a 100644 --- a/io/zenoh-transport/tests/unicast_shm.rs +++ b/io/zenoh-transport/tests/unicast_shm.rs @@ -378,7 +378,7 @@ mod tests { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_tcp_shm() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 14000).parse().unwrap(); run(&endpoint, false).await; } @@ -386,7 +386,7 @@ mod tests { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_tcp_shm_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("tcp/127.0.0.1:{}", 14001).parse().unwrap(); run(&endpoint, true).await; } @@ -394,7 +394,7 @@ mod tests { #[cfg(feature = "transport_ws")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_ws_shm() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 14010).parse().unwrap(); run(&endpoint, false).await; } @@ -402,7 +402,7 @@ mod tests { #[cfg(feature = "transport_ws")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_ws_shm_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = format!("ws/127.0.0.1:{}", 14011).parse().unwrap(); run(&endpoint, true).await; } @@ -410,7 +410,7 @@ mod tests { #[cfg(feature = "transport_unixpipe")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unixpipe_shm() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/transport_unixpipe_shm".parse().unwrap(); run(&endpoint, false).await; } @@ -418,7 +418,7 @@ mod tests { #[cfg(feature = "transport_unixpipe")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unixpipe_shm_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint: EndPoint = "unixpipe/transport_unixpipe_shm_with_lowlatency_transport" .parse() .unwrap(); diff --git a/io/zenoh-transport/tests/unicast_simultaneous.rs b/io/zenoh-transport/tests/unicast_simultaneous.rs index 277c9efda3..5cd8224fc2 100644 --- a/io/zenoh-transport/tests/unicast_simultaneous.rs +++ b/io/zenoh-transport/tests/unicast_simultaneous.rs @@ -299,7 +299,7 @@ mod tests { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_tcp_simultaneous() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint01: Vec = vec![ format!("tcp/127.0.0.1:{}", 15000).parse().unwrap(), format!("tcp/127.0.0.1:{}", 15001).parse().unwrap(), @@ -320,7 +320,7 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_unixpipe_simultaneous() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint01: Vec = vec![ "unixpipe/transport_unixpipe_simultaneous".parse().unwrap(), "unixpipe/transport_unixpipe_simultaneous2".parse().unwrap(), @@ -341,7 +341,7 @@ mod tests { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] #[ignore] async fn transport_ws_simultaneous() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let endpoint01: Vec = vec![ format!("ws/127.0.0.1:{}", 15020).parse().unwrap(), diff --git a/io/zenoh-transport/tests/unicast_transport.rs b/io/zenoh-transport/tests/unicast_transport.rs index 63ece1eab9..7e736710d8 100644 --- a/io/zenoh-transport/tests/unicast_transport.rs +++ b/io/zenoh-transport/tests/unicast_transport.rs @@ -594,7 +594,7 @@ async fn run_with_lowlatency_transport( #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_tcp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ @@ -619,7 +619,7 @@ async fn transport_unicast_tcp_only() { #[cfg(feature = "transport_tcp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_tcp_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![format!("tcp/127.0.0.1:{}", 16100).parse().unwrap()]; @@ -641,7 +641,7 @@ async fn transport_unicast_tcp_only_with_lowlatency_transport() { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_udp_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![ @@ -666,7 +666,7 @@ async fn transport_unicast_udp_only() { #[cfg(feature = "transport_udp")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_udp_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![format!("udp/127.0.0.1:{}", 16110).parse().unwrap()]; @@ -688,7 +688,7 @@ async fn transport_unicast_udp_only_with_lowlatency_transport() { #[cfg(all(feature = "transport_unixsock-stream", target_family = "unix"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_unix_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let f1 = "zenoh-test-unix-socket-5.sock"; let _ = std::fs::remove_file(f1); @@ -714,7 +714,7 @@ async fn transport_unicast_unix_only() { #[cfg(all(feature = "transport_unixsock-stream", target_family = "unix"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_unix_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let f1 = "zenoh-test-unix-socket-5-lowlatency.sock"; let _ = std::fs::remove_file(f1); @@ -740,7 +740,7 @@ async fn transport_unicast_unix_only_with_lowlatency_transport() { #[cfg(feature = "transport_ws")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_ws_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![ @@ -773,7 +773,7 @@ async fn transport_unicast_ws_only() { #[cfg(feature = "transport_ws")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_ws_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locators let endpoints: Vec = vec![format!("ws/127.0.0.1:{}", 16120).parse().unwrap()]; @@ -803,7 +803,7 @@ async fn transport_unicast_ws_only_with_lowlatency_transport() { #[cfg(feature = "transport_unixpipe")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_unixpipe_only() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![ @@ -828,7 +828,7 @@ async fn transport_unicast_unixpipe_only() { #[cfg(feature = "transport_unixpipe")] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_unixpipe_only_with_lowlatency_transport() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![ @@ -854,7 +854,7 @@ async fn transport_unicast_unixpipe_only_with_lowlatency_transport() { #[cfg(all(feature = "transport_tcp", feature = "transport_udp"))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_tcp_udp() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let endpoints: Vec = vec![ @@ -885,7 +885,7 @@ async fn transport_unicast_tcp_udp() { ))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_tcp_unix() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let f1 = "zenoh-test-unix-socket-6.sock"; let _ = std::fs::remove_file(f1); @@ -919,7 +919,7 @@ async fn transport_unicast_tcp_unix() { ))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_udp_unix() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let f1 = "zenoh-test-unix-socket-7.sock"; let _ = std::fs::remove_file(f1); @@ -954,7 +954,7 @@ async fn transport_unicast_udp_unix() { ))] #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn transport_unicast_tcp_udp_unix() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let f1 = "zenoh-test-unix-socket-8.sock"; let _ = std::fs::remove_file(f1); @@ -988,7 +988,7 @@ async fn transport_unicast_tcp_udp_unix() { async fn transport_unicast_tls_only_server() { use zenoh_link::tls::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let mut endpoint: EndPoint = format!("tls/localhost:{}", 16070).parse().unwrap(); @@ -1034,7 +1034,7 @@ async fn transport_unicast_tls_only_server() { async fn transport_unicast_quic_only_server() { use zenoh_link::quic::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let mut endpoint: EndPoint = format!("quic/localhost:{}", 16080).parse().unwrap(); endpoint @@ -1079,7 +1079,7 @@ async fn transport_unicast_quic_only_server() { async fn transport_unicast_tls_only_mutual_success() { use zenoh_link::tls::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let client_auth = "true"; @@ -1151,7 +1151,7 @@ async fn transport_unicast_tls_only_mutual_no_client_certs_failure() { use std::vec; use zenoh_link::tls::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // Define the locator let mut client_endpoint: EndPoint = ("tls/localhost:10462").parse().unwrap(); @@ -1219,7 +1219,7 @@ async fn transport_unicast_tls_only_mutual_no_client_certs_failure() { fn transport_unicast_tls_only_mutual_wrong_client_certs_failure() { use zenoh_link::tls::config::*; - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let client_auth = "true"; diff --git a/plugins/zenoh-plugin-example/src/lib.rs b/plugins/zenoh-plugin-example/src/lib.rs index 777dbb74d4..2b3450f804 100644 --- a/plugins/zenoh-plugin-example/src/lib.rs +++ b/plugins/zenoh-plugin-example/src/lib.rs @@ -140,7 +140,7 @@ impl Drop for RunningPlugin { } async fn run(runtime: Runtime, selector: KeyExpr<'_>, flag: Arc) { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); // create a zenoh Session that shares the same Runtime than zenohd let session = zenoh::init(runtime).res().await.unwrap(); diff --git a/plugins/zenoh-plugin-rest/examples/z_serve_sse.rs b/plugins/zenoh-plugin-rest/examples/z_serve_sse.rs index 324a900dda..e7d44d8ce4 100644 --- a/plugins/zenoh-plugin-rest/examples/z_serve_sse.rs +++ b/plugins/zenoh-plugin-rest/examples/z_serve_sse.rs @@ -33,7 +33,7 @@ if(typeof(EventSource) !== "undefined") { #[async_std::main] async fn main() { // initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let config = parse_args(); let key = keyexpr::new("demo/sse").unwrap(); diff --git a/plugins/zenoh-plugin-rest/src/lib.rs b/plugins/zenoh-plugin-rest/src/lib.rs index ca4cf6c174..459df5c998 100644 --- a/plugins/zenoh-plugin-rest/src/lib.rs +++ b/plugins/zenoh-plugin-rest/src/lib.rs @@ -227,7 +227,7 @@ impl Plugin for RestPlugin { // Try to initiate login. // Required in case of dynamic lib, otherwise no logs. // But cannot be done twice in case of static link. - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); tracing::debug!("REST plugin {}", LONG_VERSION.as_str()); let runtime_conf = runtime.config().lock(); @@ -476,7 +476,7 @@ pub async fn run(runtime: Runtime, conf: Config) -> ZResult<()> { // Try to initiate login. // Required in case of dynamic lib, otherwise no logs. // But cannot be done twice in case of static link. - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let zid = runtime.zid().to_string(); let session = zenoh::init(runtime).res().await.unwrap(); diff --git a/plugins/zenoh-plugin-storage-manager/src/lib.rs b/plugins/zenoh-plugin-storage-manager/src/lib.rs index 9f11141fea..b577a5f4ff 100644 --- a/plugins/zenoh-plugin-storage-manager/src/lib.rs +++ b/plugins/zenoh-plugin-storage-manager/src/lib.rs @@ -66,7 +66,7 @@ impl Plugin for StoragesPlugin { type Instance = zenoh::plugins::RunningPlugin; fn start(name: &str, runtime: &Self::StartArgs) -> ZResult { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); tracing::debug!("StorageManager plugin {}", Self::PLUGIN_VERSION); let config = { PluginConfig::try_from((name, runtime.config().lock().plugin(name).unwrap())) }?; @@ -99,7 +99,7 @@ impl StorageRuntimeInner { // Try to initiate login. // Required in case of dynamic lib, otherwise no logs. // But cannot be done twice in case of static link. - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let PluginConfig { name, backend_search_dirs, diff --git a/zenoh-ext/examples/examples/z_member.rs b/zenoh-ext/examples/examples/z_member.rs index f660482a3c..5eef7882fc 100644 --- a/zenoh-ext/examples/examples/z_member.rs +++ b/zenoh-ext/examples/examples/z_member.rs @@ -20,7 +20,7 @@ use zenoh_ext::group::*; #[tokio::main] async fn main() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let z = Arc::new(zenoh::open(Config::default()).res().await.unwrap()); let member = Member::new(z.zid().to_string()) .unwrap() diff --git a/zenoh-ext/examples/examples/z_pub_cache.rs b/zenoh-ext/examples/examples/z_pub_cache.rs index 332e3f7822..58eb7962c9 100644 --- a/zenoh-ext/examples/examples/z_pub_cache.rs +++ b/zenoh-ext/examples/examples/z_pub_cache.rs @@ -21,7 +21,7 @@ use zenoh_ext_examples::CommonArgs; #[tokio::main] async fn main() { // Initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, value, history, prefix, complete) = parse_args(); diff --git a/zenoh-ext/examples/examples/z_query_sub.rs b/zenoh-ext/examples/examples/z_query_sub.rs index 3622c78e7c..ae919c2c10 100644 --- a/zenoh-ext/examples/examples/z_query_sub.rs +++ b/zenoh-ext/examples/examples/z_query_sub.rs @@ -22,7 +22,7 @@ use zenoh_ext_examples::CommonArgs; #[tokio::main] async fn main() { // Initiate logging - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, key_expr, query) = parse_args(); diff --git a/zenoh-ext/examples/examples/z_view_size.rs b/zenoh-ext/examples/examples/z_view_size.rs index a7d95ae603..66e79cd301 100644 --- a/zenoh-ext/examples/examples/z_view_size.rs +++ b/zenoh-ext/examples/examples/z_view_size.rs @@ -21,7 +21,7 @@ use zenoh_ext_examples::CommonArgs; #[tokio::main] async fn main() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (config, group_name, id, size, timeout) = parse_args(); diff --git a/zenoh/tests/acl.rs b/zenoh/tests/acl.rs index fec29515db..6f8539f659 100644 --- a/zenoh/tests/acl.rs +++ b/zenoh/tests/acl.rs @@ -26,7 +26,7 @@ mod test { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn test_acl() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); test_pub_sub_deny().await; test_pub_sub_allow().await; test_pub_sub_deny_then_allow().await; diff --git a/zenoh/tests/interceptors.rs b/zenoh/tests/interceptors.rs index 048bb1ae1a..d74a12c17f 100644 --- a/zenoh/tests/interceptors.rs +++ b/zenoh/tests/interceptors.rs @@ -59,7 +59,7 @@ impl IntervalCounter { } fn downsampling_by_keyexpr_impl(egress: bool) { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); use zenoh::prelude::sync::*; @@ -176,7 +176,7 @@ fn downsampling_by_keyexpr() { #[cfg(unix)] fn downsampling_by_interface_impl(egress: bool) { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); use zenoh::prelude::sync::*; @@ -278,7 +278,7 @@ fn downsampling_by_interface() { #[test] #[should_panic(expected = "unknown variant `down`")] fn downsampling_config_error_wrong_strategy() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); use zenoh::prelude::sync::*; diff --git a/zenoh/tests/routing.rs b/zenoh/tests/routing.rs index bd112c0314..8d83d6a10b 100644 --- a/zenoh/tests/routing.rs +++ b/zenoh/tests/routing.rs @@ -365,7 +365,7 @@ impl Recipe { // And the message transmission should work even if the common node disappears after a while. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn gossip() -> Result<()> { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let locator = String::from("tcp/127.0.0.1:17446"); let ke = String::from("testKeyExprGossip"); @@ -433,7 +433,7 @@ async fn gossip() -> Result<()> { // Simulate two peers connecting to a router but not directly reachable to each other can exchange messages via the brokering by the router. #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn static_failover_brokering() -> Result<()> { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let locator = String::from("tcp/127.0.0.1:17449"); let ke = String::from("testKeyExprStaticFailoverBrokering"); let msg_size = 8; @@ -494,7 +494,7 @@ async fn static_failover_brokering() -> Result<()> { // Total cases = 2 x 4 x 6 = 48 #[tokio::test(flavor = "multi_thread", worker_threads = 9)] async fn three_node_combination() -> Result<()> { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let modes = [WhatAmI::Peer, WhatAmI::Client]; let delay_in_secs = [ (0, 1, 2), @@ -625,7 +625,7 @@ async fn three_node_combination() -> Result<()> { // Total cases = 2 x 8 = 16 #[tokio::test(flavor = "multi_thread", worker_threads = 8)] async fn two_node_combination() -> Result<()> { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); #[derive(Clone, Copy)] struct IsFirstListen(bool); diff --git a/zenoh/tests/session.rs b/zenoh/tests/session.rs index c70a10160b..1c18a16c50 100644 --- a/zenoh/tests/session.rs +++ b/zenoh/tests/session.rs @@ -184,7 +184,7 @@ async fn test_session_qryrep(peer01: &Session, peer02: &Session, reliability: Re #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn zenoh_session_unicast() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (peer01, peer02) = open_session_unicast(&["tcp/127.0.0.1:17447"]).await; test_session_pubsub(&peer01, &peer02, Reliability::Reliable).await; test_session_qryrep(&peer01, &peer02, Reliability::Reliable).await; @@ -193,7 +193,7 @@ async fn zenoh_session_unicast() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn zenoh_session_multicast() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (peer01, peer02) = open_session_multicast("udp/224.0.0.1:17448", "udp/224.0.0.1:17448").await; test_session_pubsub(&peer01, &peer02, Reliability::BestEffort).await; diff --git a/zenoh/tests/unicity.rs b/zenoh/tests/unicity.rs index 03fca50170..e0f3f3ab4f 100644 --- a/zenoh/tests/unicity.rs +++ b/zenoh/tests/unicity.rs @@ -251,7 +251,7 @@ async fn test_unicity_qryrep(s01: &Session, s02: &Session, s03: &Session) { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn zenoh_unicity_p2p() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let (s01, s02, s03) = open_p2p_sessions().await; test_unicity_pubsub(&s01, &s02, &s03).await; @@ -261,7 +261,7 @@ async fn zenoh_unicity_p2p() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn zenoh_unicity_brokered() { - zenoh_util::init_log_from_env(); + zenoh_util::try_init_log_from_env(); let r = open_router_session().await; let (s01, s02, s03) = open_client_sessions().await;