pub struct Layer<O: Output> { /* private fields */ }Expand description
A Layer implementation that displays all spans that own an event
when it occurs.
When an event is printed, all the spans are printed. By default, if a new event occurs inside the same span, just the event is printed. Otherwise, only the divergent part of the span hierarchy will be printed.
Spans are normally not printed unless an event occurs within them. This behavior can be
changed so that they are always printed when entered by calling Builder::log_spans.
Fields of spans and events are printed inline, so that each line is a log entry. However,
calling Builder::multiline prints each field in a separate line.
If the feature timestamp is enabled, by default the timestamp is printed for each entry.
However, it might be useful to omit it if, e.g., using jornald.
That can be achieved by calling Builder::omit_timestamp.
§Examples
let layer = Layer::builder(Stdout).build();
let subscriber = tracing_subscriber::registry().with(layer);
tracing::subscriber::set_global_default(subscriber).unwrap();Implementations§
Trait Implementations§
Source§impl<O: Output> Layer<Registry> for Layer<O>
impl<O: Output> Layer<Registry> for Layer<O>
Source§fn on_new_span(
&self,
attrs: &Attributes<'_>,
id: &Id,
ctx: Context<'_, Registry>,
)
fn on_new_span( &self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, Registry>, )
Attributes and Id.Source§fn on_event(&self, event: &Event<'_>, ctx: Context<'_, Registry>)
fn on_event(&self, event: &Event<'_>, ctx: Context<'_, Registry>)
Source§fn on_close(&self, id: Id, ctx: Context<'_, Registry>)
fn on_close(&self, id: Id, ctx: Context<'_, Registry>)
Source§fn on_register_dispatch(&self, subscriber: &Dispatch)
fn on_register_dispatch(&self, subscriber: &Dispatch)
Subscriber. Read moreSource§fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
Subscriber::register_callsite. Read moreSource§fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool
fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool
true if this layer is interested in a span or event with the
given metadata in the current Context, similarly to
Subscriber::enabled. Read moreSource§fn on_record(&self, _span: &Id, _values: &Record<'_>, _ctx: Context<'_, S>)
fn on_record(&self, _span: &Id, _values: &Record<'_>, _ctx: Context<'_, S>)
Id recorded the given
values.Source§fn on_follows_from(&self, _span: &Id, _follows: &Id, _ctx: Context<'_, S>)
fn on_follows_from(&self, _span: &Id, _follows: &Id, _ctx: Context<'_, S>)
span recorded that it
follows from the span with the ID follows.Source§fn on_enter(&self, _id: &Id, _ctx: Context<'_, S>)
fn on_enter(&self, _id: &Id, _ctx: Context<'_, S>)
Source§fn on_exit(&self, _id: &Id, _ctx: Context<'_, S>)
fn on_exit(&self, _id: &Id, _ctx: Context<'_, S>)
Source§fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<'_, S>)
fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<'_, S>)
Source§fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
Layer, returning a Layered
struct implementing Layer. Read moreSource§fn with_subscriber(self, inner: S) -> Layered<Self, S>where
Self: Sized,
fn with_subscriber(self, inner: S) -> Layered<Self, S>where
Self: Sized,
Layer with the given Subscriber, returning a
Layered struct that implements Subscriber. Read more