diff --git a/tracing-subscriber/src/layer.rs b/tracing-subscriber/src/layer.rs index 5b35bfb2ff..cbddb9dd70 100644 --- a/tracing-subscriber/src/layer.rs +++ b/tracing-subscriber/src/layer.rs @@ -13,6 +13,8 @@ use std::{ any::{type_name, TypeId}, fmt, marker::PhantomData, + ops::Deref, + sync::Arc, }; /// A composable handler for `tracing` events. @@ -917,6 +919,101 @@ where } } +macro_rules! layer_impl_body { + () => { + #[inline] + fn new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) { + self.deref().new_span(attrs, id, ctx) + } + + #[inline] + fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { + self.deref().register_callsite(metadata) + } + + #[inline] + fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool { + self.deref().enabled(metadata, ctx) + } + + #[inline] + fn max_level_hint(&self) -> Option { + self.deref().max_level_hint() + } + + #[inline] + fn on_record(&self, span: &span::Id, values: &span::Record<'_>, ctx: Context<'_, S>) { + self.deref().on_record(span, values, ctx) + } + + #[inline] + fn on_follows_from(&self, span: &span::Id, follows: &span::Id, ctx: Context<'_, S>) { + self.deref().on_follows_from(span, follows, ctx) + } + + #[inline] + fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) { + self.deref().on_event(event, ctx) + } + + #[inline] + fn on_enter(&self, id: &span::Id, ctx: Context<'_, S>) { + self.deref().on_enter(id, ctx) + } + + #[inline] + fn on_exit(&self, id: &span::Id, ctx: Context<'_, S>) { + self.deref().on_exit(id, ctx) + } + + #[inline] + fn on_close(&self, id: span::Id, ctx: Context<'_, S>) { + self.deref().on_close(id, ctx) + } + + #[inline] + fn on_id_change(&self, old: &span::Id, new: &span::Id, ctx: Context<'_, S>) { + self.deref().on_id_change(old, new, ctx) + } + + #[doc(hidden)] + #[inline] + unsafe fn downcast_raw(&self, id: TypeId) -> Option<*const ()> { + self.deref().downcast_raw(id) + } + }; +} + +impl Layer for Arc +where + L: Layer, + S: Subscriber, +{ + layer_impl_body! {} +} + +impl Layer for Arc> +where + S: Subscriber, +{ + layer_impl_body! {} +} + +impl Layer for Box +where + L: Layer, + S: Subscriber, +{ + layer_impl_body! {} +} + +impl Layer for Box> +where + S: Subscriber, +{ + layer_impl_body! {} +} + impl<'a, L, S> LookupSpan<'a> for Layered where S: Subscriber + LookupSpan<'a>,