pub struct WithContextFields<F> { /* private fields */ }Expand description
A FormatEvent wrapper that enriches log events with context values.
Wraps an inner formatter and prepends context fields to every log line. Fields are discovered lazily from registry metadata on first use.
§Example
ⓘ
use tracing_subscriber::prelude::*;
use dcontext_tracing::WithContextFields;
tracing_subscriber::registry()
.with(dcontext_tracing::DcontextLayer::new())
.with(tracing_subscriber::fmt::layer()
.event_format(WithContextFields::wrap(
tracing_subscriber::fmt::format().without_time()
)))
.init();Implementations§
Source§impl<F> WithContextFields<F>
impl<F> WithContextFields<F>
Trait Implementations§
Source§impl<S, N, F> FormatEvent<S, N> for WithContextFields<F>where
F: FormatEvent<S, N>,
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'writer> FormatFields<'writer> + 'static,
impl<S, N, F> FormatEvent<S, N> for WithContextFields<F>where
F: FormatEvent<S, N>,
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'writer> FormatFields<'writer> + 'static,
Source§fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
writer: Writer<'_>,
event: &Event<'_>,
) -> Result
fn format_event( &self, ctx: &FmtContext<'_, S, N>, writer: Writer<'_>, event: &Event<'_>, ) -> Result
Auto Trait Implementations§
impl<F> Freeze for WithContextFields<F>where
F: Freeze,
impl<F> RefUnwindSafe for WithContextFields<F>where
F: RefUnwindSafe,
impl<F> Send for WithContextFields<F>where
F: Send,
impl<F> Sync for WithContextFields<F>where
F: Sync,
impl<F> Unpin for WithContextFields<F>where
F: Unpin,
impl<F> UnsafeUnpin for WithContextFields<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for WithContextFields<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more