From d2980492991f223ad05f94f5d22d380e9cfd71d8 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Sat, 30 Mar 2024 18:20:05 +0100 Subject: [PATCH] codec: make tracing feature optional for codecs (#6434) Signed-off-by: Jens Reidel --- tokio-util/Cargo.toml | 2 +- tokio-util/src/codec/framed_impl.rs | 1 - tokio-util/src/lib.rs | 3 +++ tokio-util/src/tracing.rs | 6 ++++++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tokio-util/src/tracing.rs diff --git a/tokio-util/Cargo.toml b/tokio-util/Cargo.toml index 12c3c8136..47f443aee 100644 --- a/tokio-util/Cargo.toml +++ b/tokio-util/Cargo.toml @@ -25,7 +25,7 @@ full = ["codec", "compat", "io-util", "time", "net", "rt"] net = ["tokio/net"] compat = ["futures-io",] -codec = ["tracing"] +codec = [] time = ["tokio/time","slab"] io = [] io-util = ["io", "tokio/rt", "tokio/io-util"] diff --git a/tokio-util/src/codec/framed_impl.rs b/tokio-util/src/codec/framed_impl.rs index 9a4e2a8f6..e7cb691ae 100644 --- a/tokio-util/src/codec/framed_impl.rs +++ b/tokio-util/src/codec/framed_impl.rs @@ -12,7 +12,6 @@ use std::borrow::{Borrow, BorrowMut}; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; -use tracing::trace; pin_project! { #[derive(Debug)] diff --git a/tokio-util/src/lib.rs b/tokio-util/src/lib.rs index 22ad92b8c..1df4de1b4 100644 --- a/tokio-util/src/lib.rs +++ b/tokio-util/src/lib.rs @@ -25,6 +25,9 @@ mod cfg; mod loom; cfg_codec! { + #[macro_use] + mod tracing; + pub mod codec; } diff --git a/tokio-util/src/tracing.rs b/tokio-util/src/tracing.rs new file mode 100644 index 000000000..e1e9ed082 --- /dev/null +++ b/tokio-util/src/tracing.rs @@ -0,0 +1,6 @@ +macro_rules! trace { + ($($arg:tt)*) => { + #[cfg(feature = "tracing")] + tracing::trace!($($arg)*); + }; +}