pub struct Filtered<S, F, C> { /* private fields */ }
registry
and std
only.Expand description
A Subscribe
that wraps an inner Subscribe
and adds a Filter
which
controls what spans and events are enabled for that subscriber.
This is returned by the Subscribe::with_filter
method. See the
documentation on per-subscriber filtering for details.
Implementations§
Source§impl<S, F, C> Filtered<S, F, C>
impl<S, F, C> Filtered<S, F, C>
Sourcepub fn new(subscriber: S, filter: F) -> Self
pub fn new(subscriber: S, filter: F) -> Self
Wraps the provided Subscribe
so that it is filtered by the given
Filter
.
This is equivalent to calling the Subscribe::with_filter
method.
See the documentation on per-subscriber filtering for details.
Sourcepub fn filter_mut(&mut self) -> &mut F
pub fn filter_mut(&mut self) -> &mut F
Mutably borrows the Filter
used by this subscriber.
This method is primarily expected to be used with the
reload::Handle::modify
method.
§Examples
let filtered_subscriber = fmt::subscriber().with_filter(filter::LevelFilter::WARN);
let (filtered_subscriber, reload_handle) = reload::Subscriber::new(filtered_subscriber);
info!("This will be ignored");
reload_handle.modify(|subscriber| *subscriber.filter_mut() = filter::LevelFilter::INFO);
info!("This will be logged");
Sourcepub fn inner(&self) -> &S
pub fn inner(&self) -> &S
Borrows the inner subscriber wrapped by this Filtered
subscriber.
Sourcepub fn inner_mut(&mut self) -> &mut S
pub fn inner_mut(&mut self) -> &mut S
Mutably borrows the inner subscriber wrapped by this Filtered
subscriber.
This method is primarily expected to be used with the
reload::Handle::modify
method.
§Examples
let filtered_subscriber = fmt::subscriber().with_writer(non_blocking(std::io::stderr())).with_filter(filter::LevelFilter::INFO);
let (filtered_subscriber, reload_handle) = reload::Subscriber::new(filtered_subscriber);
info!("This will be logged to stderr");
reload_handle.modify(|subscriber| *subscriber.inner_mut().writer_mut() = non_blocking(std::io::stdout()));
info!("This will be logged to stdout");
Trait Implementations§
Source§impl<C, S, F> Subscribe<C> for Filtered<S, F, C>
impl<C, S, F> Subscribe<C> for Filtered<S, F, C>
Source§fn on_register_dispatch(&self, collector: &Dispatch)
fn on_register_dispatch(&self, collector: &Dispatch)
Source§fn on_subscribe(&mut self, collector: &mut C)
fn on_subscribe(&mut self, collector: &mut C)
Source§fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
Collect::register_callsite
. Read moreSource§fn enabled(&self, metadata: &Metadata<'_>, cx: Context<'_, C>) -> bool
fn enabled(&self, metadata: &Metadata<'_>, cx: Context<'_, C>) -> bool
true
if this subscriber is interested in a span or event with the
given metadata
in the current Context
, similarly to
Collect::enabled
. Read moreSource§fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, cx: Context<'_, C>)
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, cx: Context<'_, C>)
Attributes
and Id
.Source§fn on_record(&self, span: &Id, values: &Record<'_>, cx: Context<'_, C>)
fn on_record(&self, span: &Id, values: &Record<'_>, cx: Context<'_, C>)
Id
recorded the given
values
.Source§fn on_follows_from(&self, span: &Id, follows: &Id, cx: Context<'_, C>)
fn on_follows_from(&self, span: &Id, follows: &Id, cx: Context<'_, C>)
span
recorded that it
follows from the span with the ID follows
.Source§fn on_event(&self, event: &Event<'_>, cx: Context<'_, C>)
fn on_event(&self, event: &Event<'_>, cx: Context<'_, C>)
Source§fn on_enter(&self, id: &Id, cx: Context<'_, C>)
fn on_enter(&self, id: &Id, cx: Context<'_, C>)
Source§fn on_exit(&self, id: &Id, cx: Context<'_, C>)
fn on_exit(&self, id: &Id, cx: Context<'_, C>)
Source§fn on_close(&self, id: Id, cx: Context<'_, C>)
fn on_close(&self, id: Id, cx: Context<'_, C>)
Source§fn on_id_change(&self, old: &Id, new: &Id, cx: Context<'_, C>)
fn on_id_change(&self, old: &Id, new: &Id, cx: Context<'_, C>)
Source§fn and_then<S>(self, subscriber: S) -> Layered<S, Self, C> ⓘ
fn and_then<S>(self, subscriber: S) -> Layered<S, Self, C> ⓘ
Layered
struct implementing Subscribe
. Read more