Struct tracing_subscriber::fmt::FmtContext
source · [−]pub struct FmtContext<'a, S, N> { /* private fields */ }
Expand description
Provides the current span context to a formatter.
Implementations
sourceimpl<'a, S, N> FmtContext<'a, S, N> where
S: Subscriber + for<'lookup> LookupSpan<'lookup>,
N: for<'writer> FormatFields<'writer> + 'static,
impl<'a, S, N> FmtContext<'a, S, N> where
S: Subscriber + for<'lookup> LookupSpan<'lookup>,
N: for<'writer> FormatFields<'writer> + 'static,
sourcepub fn visit_spans<E, F>(&self, f: F) -> Result<(), E> where
F: FnMut(&SpanRef<'_, S>) -> Result<(), E>,
pub fn visit_spans<E, F>(&self, f: F) -> Result<(), E> where
F: FnMut(&SpanRef<'_, S>) -> Result<(), E>,
Visits every span in the current context with a closure.
The provided closure will be called first with the current span, and then with that span’s parent, and then that span’s parent, and so on until a root span is reached.
sourcepub fn metadata(&self, id: &Id) -> Option<&'static Metadata<'static>> where
S: for<'lookup> LookupSpan<'lookup>,
pub fn metadata(&self, id: &Id) -> Option<&'static Metadata<'static>> where
S: for<'lookup> LookupSpan<'lookup>,
Returns metadata for the span with the given id
, if it exists.
If this returns None
, then no span exists for that ID (either it has
closed or the ID is invalid).
sourcepub fn span(&self, id: &Id) -> Option<SpanRef<'_, S>> where
S: for<'lookup> LookupSpan<'lookup>,
pub fn span(&self, id: &Id) -> Option<SpanRef<'_, S>> where
S: for<'lookup> LookupSpan<'lookup>,
Returns stored data for the span with the given id
, if it exists.
If this returns None
, then no span exists for that ID (either it has
closed or the ID is invalid).
sourcepub fn exists(&self, id: &Id) -> bool where
S: for<'lookup> LookupSpan<'lookup>,
pub fn exists(&self, id: &Id) -> bool where
S: for<'lookup> LookupSpan<'lookup>,
Returns true
if an active span exists for the given Id
.
sourcepub fn lookup_current(&self) -> Option<SpanRef<'_, S>> where
S: for<'lookup> LookupSpan<'lookup>,
pub fn lookup_current(&self) -> Option<SpanRef<'_, S>> where
S: for<'lookup> LookupSpan<'lookup>,
Returns stored data for the span that the wrapped subscriber considers to be the current.
If this returns None
, then we are not currently within a span.
sourcepub fn scope(&self) -> Scope<'_, S>ⓘNotable traits for Scope<'a, L>impl<'a, L> Iterator for Scope<'a, L> where
L: LookupSpan<'a>, type Item = SpanRef<'a, L>;
where
S: for<'lookup> LookupSpan<'lookup>,
👎 Deprecated since 0.2.19: wraps layer::Context::scope, which is deprecated
pub fn scope(&self) -> Scope<'_, S>ⓘNotable traits for Scope<'a, L>impl<'a, L> Iterator for Scope<'a, L> where
L: LookupSpan<'a>, type Item = SpanRef<'a, L>;
where
S: for<'lookup> LookupSpan<'lookup>,
L: LookupSpan<'a>, type Item = SpanRef<'a, L>;
wraps layer::Context::scope, which is deprecated
Returns an iterator over the stored data for all the spans in the current context, starting the root of the trace tree and ending with the current span.
sourcepub fn current_span(&self) -> Current
pub fn current_span(&self) -> Current
Returns the current span for this formatter.
sourcepub fn field_format(&self) -> &N
pub fn field_format(&self) -> &N
Returns the field formatter configured by the subscriber invoking
format_event
.
The event formatter may use the returned field formatter to format the fields of any events it records.
Trait Implementations
sourceimpl<'a, S, N> Debug for FmtContext<'a, S, N>
impl<'a, S, N> Debug for FmtContext<'a, S, N>
sourceimpl<'cx, 'writer, S, N> FormatFields<'writer> for FmtContext<'cx, S, N> where
S: Subscriber + for<'lookup> LookupSpan<'lookup>,
N: FormatFields<'writer> + 'static,
impl<'cx, 'writer, S, N> FormatFields<'writer> for FmtContext<'cx, S, N> where
S: Subscriber + for<'lookup> LookupSpan<'lookup>,
N: FormatFields<'writer> + 'static,
sourcefn format_fields<R: RecordFields>(
&self,
writer: &'writer mut dyn Write,
fields: R
) -> Result
fn format_fields<R: RecordFields>(
&self,
writer: &'writer mut dyn Write,
fields: R
) -> Result
Format the provided fields
to the provided writer
, returning a result.
Auto Trait Implementations
impl<'a, S, N> RefUnwindSafe for FmtContext<'a, S, N> where
N: RefUnwindSafe,
S: RefUnwindSafe,
impl<'a, S, N> Send for FmtContext<'a, S, N> where
N: Sync,
S: Sync,
impl<'a, S, N> Sync for FmtContext<'a, S, N> where
N: Sync,
S: Sync,
impl<'a, S, N> Unpin for FmtContext<'a, S, N>
impl<'a, S, N> UnwindSafe for FmtContext<'a, S, N> where
N: RefUnwindSafe,
S: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more