diff --git a/Cargo.lock b/Cargo.lock index e317de71..babb2a66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -935,19 +935,6 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1510,17 +1497,6 @@ dependencies = [ "serde", ] -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.32", - "windows-sys 0.48.0", -] - [[package]] name = "iso8601" version = "0.6.1" @@ -4005,7 +3981,7 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "zenoh" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "base64 0.21.4", @@ -4058,20 +4034,20 @@ dependencies = [ "async-liveliness-monitor", "async-std", "clap", - "env_logger", "lazy_static", - "log", "serde_json", + "tracing", "zenoh", "zenoh-plugin-dds", "zenoh-plugin-rest", "zenoh-plugin-trait", + "zenoh-util", ] [[package]] name = "zenoh-buffers" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "zenoh-collections", ] @@ -4079,7 +4055,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "serde", "tracing", @@ -4091,12 +4067,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" [[package]] name = "zenoh-config" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "flume", "json5", @@ -4116,7 +4092,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-global-executor", "lazy_static", @@ -4128,7 +4104,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "aes 0.8.3", "hmac 0.12.1", @@ -4141,7 +4117,7 @@ dependencies = [ [[package]] name = "zenoh-ext" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "bincode", "flume", @@ -4162,7 +4138,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "hashbrown 0.14.0", "keyed-set", @@ -4176,7 +4152,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "zenoh-config", @@ -4194,7 +4170,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "flume", @@ -4217,7 +4193,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "base64 0.21.4", @@ -4245,7 +4221,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "tokio", @@ -4263,7 +4239,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "base64 0.21.4", @@ -4291,7 +4267,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "socket2 0.5.6", @@ -4312,7 +4288,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "futures", @@ -4332,7 +4308,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "futures-util", @@ -4353,7 +4329,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "proc-macro2", "quote", @@ -4371,17 +4347,16 @@ dependencies = [ "cdr", "cyclors", "derivative", - "env_logger", "flume", "futures", "git-version", "hex", "lazy_static", - "log", "regex", "rustc_version 0.4.0", "serde", "serde_json", + "tracing", "zenoh", "zenoh-collections", "zenoh-core", @@ -4393,7 +4368,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-rest" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "anyhow", "async-std", @@ -4420,7 +4395,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "const_format", "libloading", @@ -4436,7 +4411,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "const_format", "rand 0.8.5", @@ -4450,7 +4425,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "anyhow", ] @@ -4458,7 +4433,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "futures", "lazy_static", @@ -4470,7 +4445,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "event-listener 4.0.0", "futures", @@ -4484,7 +4459,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "futures", "tokio", @@ -4497,7 +4472,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-trait", "flume", @@ -4529,7 +4504,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#580f0b6142338c73d17da28b17986b0094272c6e" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=main#3537ee657358a1e269d8a7f5e74afc22af161aae" dependencies = [ "async-std", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index e4cde952..ab042904 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,17 +37,16 @@ cdr = "0.2.4" clap = "3.2.23" cyclors = { version = "0.2.0", git = "https://github.com/ZettaScaleLabs/cyclors.git", branch = "master" } derivative = "2.2.0" -env_logger = "0.10.0" flume = "0.11.0" futures = "0.3.26" git-version = "0.3.5" hex = "0.4.3" lazy_static = "1.4.0" -log = "0.4.17" regex = "1.7.1" rustc_version = "0.4" serde = "1.0.154" serde_json = "1.0.94" +tracing = "0.1" zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = [ "unstable", ] } diff --git a/zenoh-bridge-dds/Cargo.toml b/zenoh-bridge-dds/Cargo.toml index 1eb062d1..02e676cf 100644 --- a/zenoh-bridge-dds/Cargo.toml +++ b/zenoh-bridge-dds/Cargo.toml @@ -30,14 +30,14 @@ dds_shm = ["zenoh-plugin-dds/dds_shm"] async-std = { workspace = true, features = ["unstable", "attributes"] } async-liveliness-monitor = { workspace = true } clap = { workspace = true } -env_logger = { workspace = true } lazy_static = { workspace = true } -log = { workspace = true } serde_json = { workspace = true } +tracing = { workspace = true } zenoh = { workspace = true } zenoh-plugin-rest = { workspace = true } zenoh-plugin-trait = { workspace = true } zenoh-plugin-dds = { version = "0.11.0-dev", path = "../zenoh-plugin-dds/", default-features = false } +zenoh-util = { workspace = true } [[bin]] name = "zenoh-bridge-dds" diff --git a/zenoh-bridge-dds/src/main.rs b/zenoh-bridge-dds/src/main.rs index b4f692fa..f049737c 100644 --- a/zenoh-bridge-dds/src/main.rs +++ b/zenoh-bridge-dds/src/main.rs @@ -235,8 +235,8 @@ r#"--watchdog=[PERIOD] 'Experimental!! Run a watchdog thread that monitors the #[async_std::main] async fn main() { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("z=info")).init(); - log::info!("zenoh-bridge-dds {}", DDSPlugin::PLUGIN_LONG_VERSION); + zenoh_util::init_log_from_env(); + tracing::info!("zenoh-bridge-dds {}", DDSPlugin::PLUGIN_LONG_VERSION); let (config, watchdog_period) = parse_args(); let rest_plugin = config.plugin("rest").is_some(); @@ -278,7 +278,7 @@ fn run_watchdog(period: f32) { // Start a Liveliness Monitor thread for async_std Runtime let (_task, monitor) = LivelinessMonitor::start(async_std::task::spawn); std::thread::spawn(move || { - log::debug!( + tracing::debug!( "Watchdog started with period {} sec", sleep_time.as_secs_f32() ); @@ -289,7 +289,7 @@ fn run_watchdog(period: f32) { // Monitor watchdog thread itself if elapsed > sleep_time + max_sleep_delta { - log::warn!( + tracing::warn!( "Watchdog thread slept more than configured: {} seconds", elapsed.as_secs_f32() ); @@ -298,11 +298,11 @@ fn run_watchdog(period: f32) { let report = monitor.latest_report(); if report.elapsed() > report_threshold_1 { if report.elapsed() > sleep_time { - log::error!("Watchdog detecting async_std is stalled! No task scheduling since {} seconds", report.elapsed().as_secs_f32()); + tracing::error!("Watchdog detecting async_std is stalled! No task scheduling since {} seconds", report.elapsed().as_secs_f32()); } else if report.elapsed() > report_threshold_2 { - log::warn!("Watchdog detecting async_std was not scheduling tasks during the last {} ms", report.elapsed().as_micros()); + tracing::warn!("Watchdog detecting async_std was not scheduling tasks during the last {} ms", report.elapsed().as_micros()); } else { - log::info!("Watchdog detecting async_std was not scheduling tasks during the last {} ms", report.elapsed().as_micros()); + tracing::info!("Watchdog detecting async_std was not scheduling tasks during the last {} ms", report.elapsed().as_micros()); } } } diff --git a/zenoh-plugin-dds/Cargo.toml b/zenoh-plugin-dds/Cargo.toml index f5bc59f6..9996ba81 100644 --- a/zenoh-plugin-dds/Cargo.toml +++ b/zenoh-plugin-dds/Cargo.toml @@ -39,16 +39,15 @@ bincode = { workspace = true } cdr = { workspace = true } cyclors = { workspace = true } derivative = { workspace = true } -env_logger = { workspace = true } flume = { workspace = true } futures = { workspace = true } git-version = { workspace = true } hex = { workspace = true } lazy_static = { workspace = true } -log = { workspace = true } regex = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } +tracing = { workspace = true } zenoh = { workspace = true } zenoh-collections = { workspace = true } zenoh-core = { workspace = true } diff --git a/zenoh-plugin-dds/src/dds_mgt.rs b/zenoh-plugin-dds/src/dds_mgt.rs index 51a9e5ad..1680aa3a 100644 --- a/zenoh-plugin-dds/src/dds_mgt.rs +++ b/zenoh-plugin-dds/src/dds_mgt.rs @@ -15,7 +15,6 @@ use async_std::task; use cyclors::qos::{History, HistoryKind, Qos}; use cyclors::*; use flume::Sender; -use log::{debug, error, warn}; use serde::{Deserialize, Serialize, Serializer}; use std::collections::HashMap; use std::ffi::{CStr, CString}; @@ -24,6 +23,7 @@ use std::mem::MaybeUninit; use std::slice; use std::sync::Arc; use std::time::Duration; +use tracing::{debug, error, warn}; #[cfg(feature = "dds_shm")] use zenoh::buffers::{ZBuf, ZSlice}; use zenoh::prelude::*; @@ -493,14 +493,14 @@ unsafe extern "C" fn data_forwarder_listener(dr: dds_entity_t, arg: *mut std::os let raw_sample = DDSRawSample::create(zp); if *crate::LOG_PAYLOAD { - log::trace!( + tracing::trace!( "Route data from DDS {} to zenoh key={} - payload: {:02x?}", &(*pa).0, &(*pa).1, raw_sample ); } else { - log::trace!("Route data from DDS {} to zenoh key={}", &(*pa).0, &(*pa).1); + tracing::trace!("Route data from DDS {} to zenoh key={}", &(*pa).0, &(*pa).1); } let _ = (*pa) .2 @@ -541,7 +541,7 @@ pub(crate) fn create_forwarding_dds_reader( if reader >= 0 { let res = dds_reader_wait_for_historical_data(reader, qos::DDS_100MS_DURATION); if res < 0 { - log::error!( + tracing::error!( "Error calling dds_reader_wait_for_historical_data(): {}", CStr::from_ptr(dds_strretcode(-res)) .to_str() @@ -593,7 +593,7 @@ pub(crate) fn create_forwarding_dds_reader( { let si = si.assume_init(); if si[0].valid_data { - log::trace!( + tracing::trace!( "Route (periodic) data to zenoh resource with rid={}", z_key ); diff --git a/zenoh-plugin-dds/src/lib.rs b/zenoh-plugin-dds/src/lib.rs index fdef235c..411f87ce 100644 --- a/zenoh-plugin-dds/src/lib.rs +++ b/zenoh-plugin-dds/src/lib.rs @@ -19,7 +19,6 @@ use cyclors::qos::{ use cyclors::*; use flume::{unbounded, Receiver, Sender}; use futures::select; -use log::{debug, error, info, trace, warn}; use route_dds_zenoh::RouteDDSZenoh; use serde::ser::SerializeStruct; use serde::{Serialize, Serializer}; @@ -31,6 +30,7 @@ use std::mem::ManuallyDrop; use std::sync::atomic::AtomicBool; use std::sync::Arc; use std::time::Duration; +use tracing::{debug, error, info, trace, warn}; use zenoh::liveliness::LivelinessToken; use zenoh::plugins::{RunningPlugin, RunningPluginTrait, ZenohPlugin}; use zenoh::prelude::r#async::AsyncResolve; @@ -106,13 +106,13 @@ zenoh_plugin_trait::declare_plugin!(DDSPlugin); fn log_ros2_deprecation_warning() { if !LOG_ROS2_DEPRECATION_WARNING_FLAG.swap(true, std::sync::atomic::Ordering::Relaxed) { - log::warn!("------------------------------------------------------------------------------------------"); - log::warn!( + tracing::warn!("------------------------------------------------------------------------------------------"); + tracing::warn!( "ROS 2 system detected. Did you know a new Zenoh bridge dedicated to ROS 2 exists ?" ); - log::warn!("Check it out on https://github.com/eclipse-zenoh/zenoh-plugin-ros2dds"); - log::warn!("This DDS bridge will eventually be deprecated for ROS 2 usage in favor of this new bridge."); - log::warn!("------------------------------------------------------------------------------------------"); + tracing::warn!("Check it out on https://github.com/eclipse-zenoh/zenoh-plugin-ros2dds"); + tracing::warn!("This DDS bridge will eventually be deprecated for ROS 2 usage in favor of this new bridge."); + tracing::warn!("------------------------------------------------------------------------------------------"); } } @@ -133,7 +133,7 @@ impl Plugin for DDSPlugin { // Try to initiate login. // Required in case of dynamic lib, otherwise no logs. // But cannot be done twice in case of static link. - let _ = env_logger::try_init(); + zenoh_util::init_log_from_env(); let runtime_conf = runtime.config().lock(); let plugin_conf = runtime_conf @@ -151,7 +151,7 @@ pub async fn run(runtime: Runtime, config: Config) { // Try to initiate login. // Required in case of dynamic lib, otherwise no logs. // But cannot be done twice in case of static link. - let _ = env_logger::try_init(); + zenoh_util::init_log_from_env(); debug!("DDS plugin {}", DDSPlugin::PLUGIN_LONG_VERSION); debug!("DDS plugin {:?}", config); @@ -164,7 +164,7 @@ pub async fn run(runtime: Runtime, config: Config) { { Ok(session) => Arc::new(session), Err(e) => { - log::error!("Unable to init zenoh session for DDS plugin : {:?}", e); + tracing::error!("Unable to init zenoh session for DDS plugin : {:?}", e); return; } }; @@ -182,7 +182,7 @@ pub async fn run(runtime: Runtime, config: Config) { { Ok(member) => member, Err(e) => { - log::error!( + tracing::error!( "Unable to declare liveliness token for DDS plugin : {:?}", e ); diff --git a/zenoh-plugin-dds/src/ros_discovery.rs b/zenoh-plugin-dds/src/ros_discovery.rs index f41b52cc..4993601e 100644 --- a/zenoh-plugin-dds/src/ros_discovery.rs +++ b/zenoh-plugin-dds/src/ros_discovery.rs @@ -17,7 +17,6 @@ use cyclors::qos::{ Durability, History, IgnoreLocal, IgnoreLocalKind, Qos, Reliability, DDS_INFINITE_TIME, }; use cyclors::*; -use log::warn; use serde::ser::SerializeSeq; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::convert::TryInto; @@ -26,6 +25,7 @@ use std::{ ffi::{CStr, CString}, mem::MaybeUninit, }; +use tracing::warn; pub(crate) const ROS_DISCOVERY_INFO_TOPIC_NAME: &str = "ros_discovery_info"; const ROS_DISCOVERY_INFO_TOPIC_TYPE: &str = "rmw_dds_common::msg::dds_::ParticipantEntitiesInfo_"; diff --git a/zenoh-plugin-dds/src/route_dds_zenoh.rs b/zenoh-plugin-dds/src/route_dds_zenoh.rs index d0aa05a1..b547af0d 100644 --- a/zenoh-plugin-dds/src/route_dds_zenoh.rs +++ b/zenoh-plugin-dds/src/route_dds_zenoh.rs @@ -61,7 +61,7 @@ pub(crate) struct RouteDDSZenoh<'a> { impl Drop for RouteDDSZenoh<'_> { fn drop(&mut self) { if let Err(e) = delete_dds_entity(self.dds_reader) { - log::warn!("{}: error deleting DDS Reader: {}", self, e); + tracing::warn!("{}: error deleting DDS Reader: {}", self, e); } } } @@ -89,7 +89,7 @@ impl RouteDDSZenoh<'_> { ke: OwnedKeyExpr, congestion_ctrl: CongestionControl, ) -> Result, String> { - log::debug!( + tracing::debug!( "Route DDS->Zenoh ({} -> {}): creation with topic_type={}", topic_name, ke, @@ -134,7 +134,7 @@ impl RouteDDSZenoh<'_> { } (HistoryKind::KEEP_ALL, _) => usize::MAX, }; - log::debug!( + tracing::debug!( "Caching publications for TRANSIENT_LOCAL Writer on resource {} with history {} (Writer uses {:?} and DurabilityService.max_instances={})", ke, history, reader_qos.history, durability_service_qos.max_instances ); @@ -157,7 +157,7 @@ impl RouteDDSZenoh<'_> { .res() .await { - log::warn!( + tracing::warn!( "Failed to declare publisher for key {} (rid={}): {}", ke, declared_ke, diff --git a/zenoh-plugin-dds/src/route_zenoh_dds.rs b/zenoh-plugin-dds/src/route_zenoh_dds.rs index 2f5641f5..83272f34 100644 --- a/zenoh-plugin-dds/src/route_zenoh_dds.rs +++ b/zenoh-plugin-dds/src/route_zenoh_dds.rs @@ -111,7 +111,7 @@ impl RouteZenohDDS<'_> { topic_type: String, keyless: bool, ) -> Result, String> { - log::debug!( + tracing::debug!( "Route Zenoh->DDS ({} -> {}): creation with topic_type={} querying_subscriber={}", ke, topic_name, @@ -133,7 +133,7 @@ impl RouteZenohDDS<'_> { } else { // delay the routing of data for few ms in case this publication arrived // before the discovery message provoking the creation of the Data Writer - log::debug!( + tracing::debug!( "Route Zenoh->DDS ({} -> {}): data arrived but no DDS Writer yet to route it... wait 3s for discovery forwarding msg", s.key_expr, &ton @@ -149,7 +149,7 @@ impl RouteZenohDDS<'_> { do_route_data(s, &ton2, dw); break; } else { - log::warn!( + tracing::warn!( "Route Zenoh->DDS ({} -> {}): still no DDS Writer after 3s - drop incoming data!", ke, &ton2 @@ -164,7 +164,7 @@ impl RouteZenohDDS<'_> { let zenoh_subscriber = if querying_subscriber { // query all PublicationCaches on "/*/" let query_selector: Selector = (*KE_PREFIX_PUB_CACHE / *KE_ANY_1_SEGMENT / &ke).into(); - log::debug!( + tracing::debug!( "Route Zenoh->DDS ({} -> {}): query historical data from everybody for TRANSIENT_LOCAL Reader on {}", ke, topic_name, @@ -227,7 +227,7 @@ impl RouteZenohDDS<'_> { let old = self.dds_writer.load(Ordering::SeqCst); if old == DDS_ENTITY_NULL { - log::debug!("{}: create DDS Writer", self); + tracing::debug!("{}: create DDS Writer", self); let dw = create_forwarding_dds_writer( data_participant, self.topic_name.clone(), @@ -242,12 +242,12 @@ impl RouteZenohDDS<'_> { { // another task managed to create the DDS Writer before this task // delete the DDS Writer created here - log::debug!( + tracing::debug!( "{}: delete DDS Writer since another task created one concurrently", self ); if let Err(e) = delete_dds_entity(dw) { - log::warn!( + tracing::warn!( "{}: failed to delete DDS Writer created in concurrence of another task: {}", self, e ) @@ -263,7 +263,7 @@ impl RouteZenohDDS<'_> { .swap(DDS_ENTITY_NULL, std::sync::atomic::Ordering::Relaxed); if dds_entity != DDS_ENTITY_NULL { if let Err(e) = delete_dds_entity(dds_entity) { - log::warn!("{}: error deleting DDS Writer: {}", self, e); + tracing::warn!("{}: error deleting DDS Writer: {}", self, e); } } } @@ -279,7 +279,7 @@ impl RouteZenohDDS<'_> { { if let ZSubscriber::FetchingSubscriber(sub) = &mut self.zenoh_subscriber { let s = selector(); - log::debug!( + tracing::debug!( "Route Zenoh->DDS ({} -> {}): query historical publications from {}", sub.key_expr(), self.topic_name, @@ -304,7 +304,7 @@ impl RouteZenohDDS<'_> { .res() .await { - log::warn!( + tracing::warn!( "{}: query for historical publications on {} failed: {}", self, s, @@ -356,14 +356,14 @@ impl RouteZenohDDS<'_> { fn do_route_data(s: Sample, topic_name: &str, data_writer: dds_entity_t) { if *LOG_PAYLOAD { - log::trace!( + tracing::trace!( "Route Zenoh->DDS ({} -> {}): routing data - payload: {:?}", s.key_expr, &topic_name, s.value.payload ); } else { - log::trace!( + tracing::trace!( "Route Zenoh->DDS ({} -> {}): routing data", s.key_expr, &topic_name @@ -399,7 +399,7 @@ fn do_route_data(s: Sample, topic_name: &str, data_writer: dds_entity_t) { let mut sertype_ptr: *const ddsi_sertype = std::ptr::null_mut(); let ret = dds_get_entity_sertype(data_writer, &mut sertype_ptr); if ret < 0 { - log::warn!( + tracing::warn!( "Route Zenoh->DDS ({} -> {}): can't route data; sertype lookup failed ({})", s.key_expr, topic_name,