diff --git a/Cargo.lock b/Cargo.lock index 5e25892..7de0659 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -868,19 +868,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[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" @@ -1505,17 +1492,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.9", - "rustix 0.38.32", - "windows-sys 0.48.0", -] - [[package]] name = "iso8601" version = "0.6.1" @@ -4278,7 +4254,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "base64 0.21.4", @@ -4330,20 +4306,20 @@ version = "0.11.0-dev" dependencies = [ "async-std", "clap", - "env_logger", "lazy_static", - "log", "serde_json", + "tracing", "zenoh", "zenoh-plugin-mqtt", "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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "zenoh-collections", ] @@ -4351,7 +4327,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "serde", "tracing", @@ -4363,12 +4339,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#279317cb1ee8594ca109031a755e3e56dff9b188" [[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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "flume 0.11.0", "json5", @@ -4388,7 +4364,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-global-executor", "lazy_static", @@ -4400,7 +4376,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "aes 0.8.3", "hmac 0.12.1", @@ -4413,7 +4389,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "bincode", "flume 0.11.0", @@ -4434,7 +4410,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "hashbrown 0.14.0", "keyed-set", @@ -4448,7 +4424,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "zenoh-config", @@ -4466,7 +4442,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "flume 0.11.0", @@ -4489,7 +4465,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "base64 0.21.4", @@ -4517,7 +4493,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "tokio", @@ -4535,7 +4511,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "base64 0.21.4", @@ -4563,7 +4539,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "socket2 0.5.6", @@ -4584,7 +4560,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "futures", @@ -4604,7 +4580,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "futures-util", @@ -4625,7 +4601,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "proc-macro2", "quote", @@ -4642,13 +4618,11 @@ dependencies = [ "async-trait", "base64 0.21.4", "derivative", - "env_logger", "flume 0.10.14", "futures", "git-version", "hex", "lazy_static", - "log", "ntex", "ntex-mqtt", "ntex-tls", @@ -4659,17 +4633,19 @@ dependencies = [ "secrecy", "serde", "serde_json", + "tracing", "zenoh", "zenoh-collections", "zenoh-core", "zenoh-ext", "zenoh-plugin-trait", + "zenoh-util", ] [[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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "anyhow", "async-std", @@ -4696,7 +4672,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "const_format", "libloading", @@ -4712,7 +4688,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "const_format", "rand 0.8.5", @@ -4726,7 +4702,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "anyhow", ] @@ -4734,7 +4710,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "futures", "lazy_static", @@ -4746,7 +4722,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "event-listener 4.0.0", "futures", @@ -4760,7 +4736,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "futures", "tokio", @@ -4773,7 +4749,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-trait", "flume 0.11.0", @@ -4805,7 +4781,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#279317cb1ee8594ca109031a755e3e56dff9b188" dependencies = [ "async-std", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index b19b663..639c17d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,13 +31,11 @@ async-trait = "0.1.66" base64 = "0.21.4" clap = "3.2.23" derivative = "2.2.0" -env_logger = "0.10.0" flume = "0.10.14" futures = "0.3.26" git-version = "0.3.5" hex = "0.4.3" lazy_static = "1.4.0" -log = "0.4.17" ntex = "0.7.17" ntex-mqtt = "0.12.16" ntex-tls = "0.3.2" @@ -48,6 +46,7 @@ rustls-pemfile = "1.0.4" secrecy = { version = "0.8.0", features = ["serde", "alloc"] } 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", ] } @@ -58,6 +57,7 @@ zenoh-ext = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/ze ] } zenoh-plugin-rest = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false } zenoh-plugin-trait = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", default-features = false } +zenoh-util = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" } [profile.release] debug = false diff --git a/zenoh-bridge-mqtt/Cargo.toml b/zenoh-bridge-mqtt/Cargo.toml index f520cc6..4701ffa 100644 --- a/zenoh-bridge-mqtt/Cargo.toml +++ b/zenoh-bridge-mqtt/Cargo.toml @@ -26,14 +26,14 @@ publish = false [dependencies] async-std = { workspace = true, features = ["unstable", "attributes"] } clap = { workspace = true } -env_logger = { workspace = true } lazy_static = { workspace = true } -log = { workspace = true } +tracing = { workspace = true } serde_json = { workspace = true } zenoh = { workspace = true } zenoh-plugin-rest = { workspace = true } zenoh-plugin-trait = { workspace = true } zenoh-plugin-mqtt = { version = "0.11.0-dev", path = "../zenoh-plugin-mqtt/", default-features = false } +zenoh-util = { workspace = true } [[bin]] name = "zenoh-bridge-mqtt" diff --git a/zenoh-bridge-mqtt/src/main.rs b/zenoh-bridge-mqtt/src/main.rs index 0df2e2c..4780d94 100644 --- a/zenoh-bridge-mqtt/src/main.rs +++ b/zenoh-bridge-mqtt/src/main.rs @@ -187,8 +187,9 @@ r#"--root-ca-certificate=[FILE] 'Path to the certificate of the certificate au #[async_std::main] async fn main() { - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("z=info")).init(); - log::info!( + zenoh_util::init_log_from_env(); + + tracing::info!( "zenoh-bridge-mqtt {}", zenoh_plugin_mqtt::MqttPlugin::PLUGIN_LONG_VERSION ); diff --git a/zenoh-plugin-mqtt/Cargo.toml b/zenoh-plugin-mqtt/Cargo.toml index 035cf45..24f89a5 100644 --- a/zenoh-plugin-mqtt/Cargo.toml +++ b/zenoh-plugin-mqtt/Cargo.toml @@ -37,13 +37,12 @@ async-std = { workspace = true, features = ["unstable", "attributes"] } async-trait = { workspace = true } base64 = { 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 } +tracing = { workspace = true } ntex = { workspace = true, features = ["async-std", "rustls"] } ntex-mqtt = { workspace = true } ntex-tls = { workspace = true } @@ -58,6 +57,7 @@ zenoh-collections = { workspace = true } zenoh-core = { workspace = true } zenoh-ext = { workspace = true } zenoh-plugin-trait = { workspace = true } +zenoh-util = { workspace = true } [build-dependencies] rustc_version = { workspace = true } diff --git a/zenoh-plugin-mqtt/src/lib.rs b/zenoh-plugin-mqtt/src/lib.rs index fa7346b..a4ae108 100644 --- a/zenoh-plugin-mqtt/src/lib.rs +++ b/zenoh-plugin-mqtt/src/lib.rs @@ -79,7 +79,7 @@ impl Plugin for MqttPlugin { // 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 @@ -115,9 +115,9 @@ async fn run( // 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(); - log::debug!("MQTT plugin {}", MqttPlugin::PLUGIN_LONG_VERSION); - log::debug!("MQTT plugin {:?}", config); + zenoh_util::init_log_from_env(); + tracing::debug!("MQTT plugin {}", MqttPlugin::PLUGIN_LONG_VERSION); + tracing::debug!("MQTT plugin {:?}", config); // init Zenoh Session with provided Runtime let zsession = match zenoh::init(runtime) @@ -128,7 +128,7 @@ async fn run( { Ok(session) => Arc::new(session), Err(e) => { - log::error!("Unable to init zenoh session for MQTT plugin : {:?}", e); + tracing::error!("Unable to init zenoh session for MQTT plugin : {:?}", e); return; } }; @@ -137,7 +137,7 @@ async fn run( let admin_keyexpr_prefix = *KE_PREFIX_ADMIN_SPACE / &zsession.zid().into_keyexpr() / ke_for_sure!("mqtt"); let admin_keyexpr_expr = (&admin_keyexpr_prefix) / ke_for_sure!("**"); - log::debug!("Declare admin space on {}", admin_keyexpr_expr); + tracing::debug!("Declare admin space on {}", admin_keyexpr_expr); let config2 = config.clone(); let _admin_queryable = zsession .declare_queryable(admin_keyexpr_expr) @@ -147,7 +147,9 @@ async fn run( .expect("Failed to create AdminSpace queryable"); if auth_dictionary.is_some() && tls_config.is_none() { - log::warn!("Warning: MQTT client username/password authentication enabled without TLS!"); + tracing::warn!( + "Warning: MQTT client username/password authentication enabled without TLS!" + ); } // Start MQTT Server task @@ -444,13 +446,13 @@ fn create_mqtt_server( fn treat_admin_query(query: Query, admin_keyexpr_prefix: &keyexpr, config: &Config) { let selector = query.selector(); - log::debug!("Query on admin space: {:?}", selector); + tracing::debug!("Query on admin space: {:?}", selector); // get the list of sub-key expressions that will match the same stored keys than // the selector, if those keys had the admin_keyexpr_prefix. let sub_kes = selector.key_expr.strip_prefix(admin_keyexpr_prefix); if sub_kes.is_empty() { - log::error!("Received query for admin space: '{}' - but it's not prefixed by admin_keyexpr_prefix='{}'", selector, admin_keyexpr_prefix); + tracing::error!("Received query for admin space: '{}' - but it's not prefixed by admin_keyexpr_prefix='{}'", selector, admin_keyexpr_prefix); return; } @@ -476,7 +478,7 @@ fn treat_admin_query(query: Query, admin_keyexpr_prefix: &keyexpr, config: &Conf let admin_keyexpr = admin_keyexpr_prefix / ke; use zenoh::prelude::sync::SyncResolve; if let Err(e) = query.reply(Ok(Sample::new(admin_keyexpr, v))).res_sync() { - log::warn!("Error replying to admin query {:?}: {}", query, e); + tracing::warn!("Error replying to admin query {:?}: {}", query, e); } } } @@ -541,13 +543,13 @@ async fn handshake_v3<'a>( handshake.packet().password.as_ref(), ) { Ok(_) => { - log::info!("MQTT client {} connects using v3", client_id); + tracing::info!("MQTT client {} connects using v3", client_id); let session = MqttSessionState::new(client_id, zsession, config, handshake.sink().into()); Ok(handshake.ack(session, false)) } Err(err) => { - log::warn!( + tracing::warn!( "MQTT client {} connect using v3 rejected: {}", client_id, err @@ -572,7 +574,7 @@ async fn control_v3( session: v3::Session>, control: v3::ControlMessage, ) -> Result { - log::trace!( + tracing::trace!( "MQTT client {} sent control: {:?}", session.client_id, control @@ -581,14 +583,14 @@ async fn control_v3( match control { v3::ControlMessage::Ping(ref msg) => Ok(msg.ack()), v3::ControlMessage::Disconnect(msg) => { - log::debug!("MQTT client {} disconnected", session.client_id); + tracing::debug!("MQTT client {} disconnected", session.client_id); session.sink().close(); Ok(msg.ack()) } v3::ControlMessage::Subscribe(mut msg) => { for mut s in msg.iter_mut() { let topic = s.topic().as_str(); - log::debug!( + tracing::debug!( "MQTT client {} subscribes to '{}'", session.client_id, topic @@ -596,7 +598,7 @@ async fn control_v3( match session.state().map_mqtt_subscription(topic).await { Ok(()) => s.confirm(v3::QoS::AtMostOnce), Err(e) => { - log::error!("Subscription to '{}' failed: {}", topic, e); + tracing::error!("Subscription to '{}' failed: {}", topic, e); s.fail() } } @@ -605,7 +607,7 @@ async fn control_v3( } v3::ControlMessage::Unsubscribe(msg) => { for topic in msg.iter() { - log::debug!( + tracing::debug!( "MQTT client {} unsubscribes from '{}'", session.client_id, topic.as_str() @@ -614,12 +616,12 @@ async fn control_v3( Ok(msg.ack()) } v3::ControlMessage::Closed(msg) => { - log::debug!("MQTT client {} closed connection", session.client_id); + tracing::debug!("MQTT client {} closed connection", session.client_id); session.sink().force_close(); Ok(msg.ack()) } v3::ControlMessage::Error(msg) => { - log::warn!( + tracing::warn!( "MQTT client {} Error received: {}", session.client_id, msg.get_ref().err @@ -627,7 +629,7 @@ async fn control_v3( Ok(msg.ack()) } v3::ControlMessage::ProtocolError(ref msg) => { - log::warn!( + tracing::warn!( "MQTT client {}: ProtocolError received: {} => disconnect it", session.client_id, msg.get_ref() @@ -635,7 +637,7 @@ async fn control_v3( Ok(control.disconnect()) } v3::ControlMessage::PeerGone(msg) => { - log::debug!( + tracing::debug!( "MQTT client {}: PeerGone => close connection", session.client_id ); @@ -659,13 +661,13 @@ async fn handshake_v5<'a>( handshake.packet().password.as_ref(), ) { Ok(_) => { - log::info!("MQTT client {} connects using v5", client_id); + tracing::info!("MQTT client {} connects using v5", client_id); let session = MqttSessionState::new(client_id, zsession, config, handshake.sink().into()); Ok(handshake.ack(session)) } Err(err) => { - log::warn!( + tracing::warn!( "MQTT client {} connect using v5 rejected: {}", client_id, err @@ -691,7 +693,7 @@ async fn control_v5( session: v5::Session>, control: v5::ControlMessage, ) -> Result { - log::trace!( + tracing::trace!( "MQTT client {} sent control: {:?}", session.client_id, control @@ -700,7 +702,7 @@ async fn control_v5( use v5::codec::{Disconnect, DisconnectReasonCode}; match control { v5::ControlMessage::Auth(_) => { - log::debug!( + tracing::debug!( "MQTT client {} wants to authenticate... not yet supported!", session.client_id ); @@ -710,14 +712,14 @@ async fn control_v5( } v5::ControlMessage::Ping(msg) => Ok(msg.ack()), v5::ControlMessage::Disconnect(msg) => { - log::debug!("MQTT client {} disconnected", session.client_id); + tracing::debug!("MQTT client {} disconnected", session.client_id); session.sink().close(); Ok(msg.ack()) } v5::ControlMessage::Subscribe(mut msg) => { for mut s in msg.iter_mut() { let topic = s.topic().as_str(); - log::debug!( + tracing::debug!( "MQTT client {} subscribes to '{}'", session.client_id, topic @@ -725,7 +727,7 @@ async fn control_v5( match session.state().map_mqtt_subscription(topic).await { Ok(()) => s.confirm(v5::QoS::AtMostOnce), Err(e) => { - log::error!("Subscription to '{}' failed: {}", topic, e); + tracing::error!("Subscription to '{}' failed: {}", topic, e); s.fail(v5::codec::SubscribeAckReason::ImplementationSpecificError) } } @@ -734,7 +736,7 @@ async fn control_v5( } v5::ControlMessage::Unsubscribe(msg) => { for topic in msg.iter() { - log::debug!( + tracing::debug!( "MQTT client {} unsubscribes from '{}'", session.client_id, topic.as_str() @@ -743,12 +745,12 @@ async fn control_v5( Ok(msg.ack()) } v5::ControlMessage::Closed(msg) => { - log::debug!("MQTT client {} closed connection", session.client_id); + tracing::debug!("MQTT client {} closed connection", session.client_id); session.sink().close(); Ok(msg.ack()) } v5::ControlMessage::Error(msg) => { - log::warn!( + tracing::warn!( "MQTT client {} Error received: {}", session.client_id, msg.get_ref().err @@ -756,7 +758,7 @@ async fn control_v5( Ok(msg.ack(DisconnectReasonCode::UnspecifiedError)) } v5::ControlMessage::ProtocolError(msg) => { - log::warn!( + tracing::warn!( "MQTT client {}: ProtocolError received: {}", session.client_id, msg.get_ref() @@ -765,7 +767,7 @@ async fn control_v5( Ok(msg.reason_code(DisconnectReasonCode::ProtocolError).ack()) } v5::ControlMessage::PeerGone(msg) => { - log::debug!( + tracing::debug!( "MQTT client {}: PeerGone => close connection", session.client_id ); diff --git a/zenoh-plugin-mqtt/src/mqtt_session_state.rs b/zenoh-plugin-mqtt/src/mqtt_session_state.rs index 710c140..cab2e2a 100644 --- a/zenoh-plugin-mqtt/src/mqtt_session_state.rs +++ b/zenoh-plugin-mqtt/src/mqtt_session_state.rs @@ -57,7 +57,7 @@ impl MqttSessionState<'_> { Locality::Any } else { // if topic is NOT allowed, subscribe to publications coming only from this plugin (for MQTT-to-MQTT routing only) - log::debug!( + tracing::debug!( "MQTT Client {}: topic '{}' is not allowed to be routed over Zenoh (see your 'allow' or 'deny' configuration) - re-publish only from MQTT publishers", self.client_id, topic @@ -76,7 +76,7 @@ impl MqttSessionState<'_> { .declare_subscriber(ke) .callback(move |sample| { if let Err(e) = route_zenoh_to_mqtt(sample, &client_id, &config, &tx) { - log::warn!("{}", e); + tracing::warn!("{}", e); } }) .allowed_origin(sub_origin) @@ -85,7 +85,7 @@ impl MqttSessionState<'_> { subs.insert(topic.into(), sub); Ok(()) } else { - log::debug!( + tracing::debug!( "MQTT Client {} already subscribes to {} => ignore", self.client_id, topic @@ -105,7 +105,7 @@ impl MqttSessionState<'_> { Locality::Any } else { // if topic is NOT allowed, publish only to this plugin (for MQTT-to-MQTT routing only) - log::trace!( + tracing::trace!( "MQTT Client {}: topic '{}' is not allowed to be routed over Zenoh (see your 'allow' or 'deny' configuration) - re-publish only to MQTT subscriber", self.client_id, topic @@ -120,7 +120,7 @@ impl MqttSessionState<'_> { }; let encoding = guess_encoding(payload.deref()); // TODO: check allow/deny - log::trace!( + tracing::trace!( "MQTT client {}: route from MQTT '{}' to Zenoh '{}' (encoding={})", self.client_id, topic, @@ -143,7 +143,7 @@ fn route_zenoh_to_mqtt( tx: &Sender<(ByteString, Bytes)>, ) -> ZResult<()> { let topic = ke_to_mqtt_topic_publish(&sample.key_expr, &config.scope)?; - log::trace!( + tracing::trace!( "MQTT client {}: route from Zenoh '{}' to MQTT '{}'", client_id, sample.key_expr, @@ -168,7 +168,7 @@ fn spawn_mqtt_publisher(client_id: String, rx: Receiver<(ByteString, Bytes)>, si Ok((topic, payload)) => { if sink.is_open() { if let Err(e) = sink.publish_at_most_once(topic, payload) { - log::trace!( + tracing::trace!( "Failed to send MQTT message for client {} - {}", client_id, e @@ -177,12 +177,12 @@ fn spawn_mqtt_publisher(client_id: String, rx: Receiver<(ByteString, Bytes)>, si break; } } else { - log::trace!("MQTT sink closed for client {}", client_id); + tracing::trace!("MQTT sink closed for client {}", client_id); break; } } Err(_) => { - log::trace!("MPSC Channel closed for client {}", client_id); + tracing::trace!("MPSC Channel closed for client {}", client_id); break; } }