diff --git a/axum-core/src/macros.rs b/axum-core/src/macros.rs index 69358a29..7d723818 100644 --- a/axum-core/src/macros.rs +++ b/axum-core/src/macros.rs @@ -1,4 +1,5 @@ /// Private API. +#[cfg(feature = "tracing")] #[doc(hidden)] #[macro_export] macro_rules! __log_rejection { @@ -7,7 +8,6 @@ macro_rules! __log_rejection { body_text = $body_text:expr, status = $status:expr, ) => { - #[cfg(feature = "tracing")] { tracing::event!( target: "axum::rejection", @@ -21,6 +21,17 @@ macro_rules! __log_rejection { }; } +#[cfg(not(feature = "tracing"))] +#[doc(hidden)] +#[macro_export] +macro_rules! __log_rejection { + ( + rejection_type = $ty:ident, + body_text = $body_text:expr, + status = $status:expr, + ) => {}; +} + /// Private API. #[doc(hidden)] #[macro_export] diff --git a/axum-extra/Cargo.toml b/axum-extra/Cargo.toml index c618861d..48c6556c 100644 --- a/axum-extra/Cargo.toml +++ b/axum-extra/Cargo.toml @@ -33,7 +33,7 @@ json-lines = [ multipart = ["dep:multer"] protobuf = ["dep:prost"] query = ["dep:serde_html_form"] -tracing = ["dep:tracing", "axum-core/tracing"] +tracing = ["dep:tracing", "axum-core/tracing", "axum/tracing"] typed-header = ["dep:headers"] typed-routing = ["dep:axum-macros", "dep:percent-encoding", "dep:serde_html_form", "dep:form_urlencoded"]