Trait tracing_subscriber::util::SubscriberInitExt[][src]

pub trait SubscriberInitExt where
    Self: Into<Dispatch>, 
{ fn set_default(self) -> DefaultGuard { ... }
fn try_init(self) -> Result<(), TryInitError> { ... }
fn init(self) { ... } }

Extension trait adding utility methods for subscriber initialization.

This trait provides extension methods to make configuring and setting a default subscriber more ergonomic. It is automatically implemented for all types that can be converted into a trace dispatcher. Since Dispatch implements From<T> for all T: Subscriber, all Subscriber implementations will implement this extension trait as well. Types which can be converted into Subscribers, such as builders that construct a Subscriber, may implement Into<Dispatch>, and will also receive an implementation of this trait.

Provided methods

fn set_default(self) -> DefaultGuard[src]

Sets self as the default subscriber in the current scope, returning a guard that will unset it when dropped.

If the “tracing-log” feature flag is enabled, this will also initialize a log compatibility layer. This allows the subscriber to consume log::Records as though they were tracing Events.

fn try_init(self) -> Result<(), TryInitError>[src]

Attempts to set self as the global default subscriber in the current scope, returning an error if one is already set.

If the “tracing-log” feature flag is enabled, this will also attempt to initialize a log compatibility layer. This allows the subscriber to consume log::Records as though they were tracing Events.

This method returns an error if a global default subscriber has already been set, or if a log logger has already been set (when the “tracing-log” feature is enabled).

fn init(self)[src]

Attempts to set self as the global default subscriber in the current scope, panicking if this fails.

If the “tracing-log” feature flag is enabled, this will also attempt to initialize a log compatibility layer. This allows the subscriber to consume log::Records as though they were tracing Events.

This method panics if a global default subscriber has already been set, or if a log logger has already been set (when the “tracing-log” feature is enabled).

Loading content...

Implementors

impl<T> SubscriberInitExt for T where
    T: Into<Dispatch>, 
[src]

Loading content...