core: Fix compile errors from __log_rejection (#2933)

This commit is contained in:
Jonas Platte 2024-09-25 07:44:35 +00:00
parent 4fc0641874
commit 6f5607785d
No known key found for this signature in database
GPG key ID: 7D261D771D915378
3 changed files with 9 additions and 4 deletions

View file

@ -50,6 +50,11 @@
#[macro_use] #[macro_use]
pub(crate) mod macros; pub(crate) mod macros;
#[doc(hidden)] // macro helpers
pub mod __private {
#[cfg(feature = "tracing")]
pub use tracing;
}
mod error; mod error;
mod ext_traits; mod ext_traits;

View file

@ -9,12 +9,12 @@ macro_rules! __log_rejection {
status = $status:expr, status = $status:expr,
) => { ) => {
{ {
tracing::event!( $crate::__private::tracing::event!(
target: "axum::rejection", target: "axum::rejection",
tracing::Level::TRACE, $crate::__private::tracing::Level::TRACE,
status = $status.as_u16(), status = $status.as_u16(),
body = $body_text, body = $body_text,
rejection_type = std::any::type_name::<$ty>(), rejection_type = ::std::any::type_name::<$ty>(),
"rejecting request", "rejecting request",
); );
} }

View file

@ -34,7 +34,7 @@ json-lines = [
multipart = ["dep:multer"] multipart = ["dep:multer"]
protobuf = ["dep:prost"] protobuf = ["dep:prost"]
query = ["dep:serde_html_form"] query = ["dep:serde_html_form"]
tracing = ["dep:tracing", "axum-core/tracing", "axum/tracing"] tracing = ["axum-core/tracing", "axum/tracing"]
typed-header = ["dep:headers"] typed-header = ["dep:headers"]
typed-routing = ["dep:axum-macros", "dep:percent-encoding", "dep:serde_html_form", "dep:form_urlencoded"] typed-routing = ["dep:axum-macros", "dep:percent-encoding", "dep:serde_html_form", "dep:form_urlencoded"]