Struct trace_tools::subscriber::SubscriberBuilder
source · [−]pub struct SubscriberBuilder { /* private fields */ }
Expand description
Builder for the trace_tools
subscriber.
This can be used to enable/disable Layer
s provided by this crate.
Implementations
sourceimpl SubscriberBuilder
impl SubscriberBuilder
sourcepub fn with_log_layer(self, logger_config: LoggerConfig) -> Self
pub fn with_log_layer(self, logger_config: LoggerConfig) -> Self
Enables the LogLayer
for this subscriber, using the parameters provided by
the given LoggerConfig
.
sourcepub fn with_default_log_layer(self) -> Self
pub fn with_default_log_layer(self) -> Self
Enables the LogLayer
for this subscriber, using the default configuration.
sourcepub fn with_flamegraph_layer<P: AsRef<Path>>(self, folded_stack_file: P) -> Self
pub fn with_flamegraph_layer<P: AsRef<Path>>(self, folded_stack_file: P) -> Self
Enables the FlamegraphLayer
for this subscriber.
The given path describes the desired output location of the folded stack file that is generated by
this layer during runtime. This file can then be used to produce a flamegraph by a Flamegrapher
instance, or by the inferno
tool.
sourcepub fn finish(self) -> Result<(TraceSubscriber, Option<Flamegrapher>), Error>
pub fn finish(self) -> Result<(TraceSubscriber, Option<Flamegrapher>), Error>
Builds and returns the TraceSubscriber
.
Errors
- Creation of the
FlamegraphLayer
failed. - Creation of the
LogLayer
failed.
Notes
- This method calls the
collect_logs
function. Anylog
records emitted will be converting intotracing
events, and therefore any external functionality that deals withlog
records may no longer function as expected. - This method does not set the global subscriber. As such, a call to
finish
can be used to further extend the return subscriber with externalLayer
s.
sourcepub fn init(self) -> Result<Option<Flamegrapher>, Error>
pub fn init(self) -> Result<Option<Flamegrapher>, Error>
Builds the TraceSubscriber
and sets it as the global default subscriber.
Returns a Result
over an Option<Flamegrapher>
. The returned option is Some
if
the LogLayer
is enabled and has been successfully initialised. If the
`LogLayer has not been enabled with the builder, it is fine to ignore this value.
Errors
- Creation of the
FlamegraphLayer
failed. - Creation of the
LogLayer
failed.
Panics
This method will panic if the flamegraph layer is enabled and the program is not built with
--cfg tokio_unstable
.
Notes
- This method calls the
collect_logs
function. Anylog
records emitted will be converting intotracing
events, and therefore any external functionality that deals withlog
records may no longer function as expected. - This method sets the global subscriber. Any further attempts to set the global subscriber (including another call to this method) will fail.
- The subscriber initialised by this method cannot be extended.
Trait Implementations
sourceimpl Default for SubscriberBuilder
impl Default for SubscriberBuilder
sourcefn default() -> SubscriberBuilder
fn default() -> SubscriberBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for SubscriberBuilder
impl Send for SubscriberBuilder
impl Sync for SubscriberBuilder
impl Unpin for SubscriberBuilder
impl UnwindSafe for SubscriberBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more