🛈 Note: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem.

For the release documentation, please see docs.rs, instead.

tracing_subscriber::fmt

Trait FormatFields

Source
pub trait FormatFields<'writer> {
    // Required method
    fn format_fields<R: RecordFields>(
        &self,
        writer: Writer<'writer>,
        fields: R,
    ) -> Result;

    // Provided method
    fn add_fields(
        &self,
        current: &'writer mut FormattedFields<Self>,
        fields: &Record<'_>,
    ) -> Result { ... }
}
Available on crate features fmt and std only.
Expand description

A type that can format a set of fields to a Writer.

FormatFields is primarily used in the context of fmt::Subscriber. Each time a span or event with fields is recorded, the subscriber will format those fields with its associated FormatFields implementation.

Required Methods§

Source

fn format_fields<R: RecordFields>( &self, writer: Writer<'writer>, fields: R, ) -> Result

Format the provided fields to the provided Writer, returning a result.

Provided Methods§

Source

fn add_fields( &self, current: &'writer mut FormattedFields<Self>, fields: &Record<'_>, ) -> Result

Record additional field(s) on an existing span.

By default, this appends a space to the current set of fields if it is non-empty, and then calls self.format_fields. If different behavior is required, the default implementation of this method can be overridden.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> FormatFields<'a> for JsonFields

Source§

impl<'cx, 'writer, C, N> FormatFields<'writer> for FmtContext<'cx, C, N>
where C: Collect + for<'lookup> LookupSpan<'lookup>, N: FormatFields<'writer> + 'static,

Source§

impl<'writer> FormatFields<'writer> for Pretty

Source§

impl<'writer, M> FormatFields<'writer> for M