logo
pub struct Filtered<L, F, S> { /* private fields */ }
Expand description

A Layer that wraps an inner Layer and adds a Filter which controls what spans and events are enabled for that layer.

This is returned by the Layer::with_filter method. See the documentation on per-layer filtering for details.

Implementations

Wraps the provided Layer so that it is filtered by the given Filter.

This is equivalent to calling the Layer::with_filter method.

See the documentation on per-layer filtering for details.

Borrows the Filter used by this layer.

Mutably borrows the Filter used by this layer.

When this layer can be mutably borrowed, this may be used to mutate the filter. Generally, this will primarily be used with the reload::Handle::modify method.

Examples
let filtered_layer = fmt::Layer::default().with_filter(filter::LevelFilter::WARN);
let (filtered_layer, reload_handle) = reload::Layer::new(filtered_layer);
info!("This will be ignored");
reload_handle.modify(|layer| *layer.filter_mut() = filter::LevelFilter::INFO);
info!("This will be logged");

Borrows the inner Layer wrapped by this Filtered layer.

Mutably borrows the inner Layer wrapped by this Filtered layer.

This method is primarily expected to be used with the reload::Handle::modify method.

Examples
let filtered_layer = fmt::layer().with_writer(non_blocking(std::io::stderr())).with_filter(filter::LevelFilter::INFO);
let (filtered_layer, reload_handle) = reload::Layer::new(filtered_layer);
info!("This will be logged to stderr");
reload_handle.modify(|layer| *layer.inner_mut().writer_mut() = non_blocking(std::io::stdout()));
info!("This will be logged to stdout");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs late initialization when attaching a Layer to a Subscriber. Read more

Registers a new callsite with this layer, returning whether or not the layer is interested in being notified about the callsite, similarly to Subscriber::register_callsite. Read more

Returns true if this layer is interested in a span or event with the given metadata in the current Context, similarly to Subscriber::enabled. Read more

Notifies this layer that a new span was constructed with the given Attributes and Id. Read more

Notifies this layer that a span with the given Id recorded the given values. Read more

Notifies this layer that a span with the ID span recorded that it follows from the span with the ID follows. Read more

Notifies this layer that an event has occurred.

Notifies this layer that a span with the given ID was entered.

Notifies this layer that the span with the given ID was exited.

Notifies this layer that the span with the given ID has been closed.

Notifies this layer that a span ID has been cloned, and that the subscriber returned a different ID. Read more

Composes this layer around the given Layer, returning a Layered struct implementing Layer. Read more

Composes this Layer with the given Subscriber, returning a Layered struct that implements Subscriber. Read more

Combines self with a Filter, returning a Filtered layer. Read more

Erases the type of this Layer, returning a Boxed dyn Layer trait object. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into #41263)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.