pub struct SubscriberBuilder { /* private fields */ }Expand description
Builder for the trace_tools subscriber.
This can be used to enable/disable Layers provided by this crate.
Implementations§
Source§impl 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
FlamegraphLayerfailed. - Creation of the
LogLayerfailed.
§Notes
- This method calls the
collect_logsfunction. Anylogrecords emitted will be converting intotracingevents, and therefore any external functionality that deals withlogrecords may no longer function as expected. - This method does not set the global subscriber. As such, a call to
finishcan be used to further extend the return subscriber with externalLayers.
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
FlamegraphLayerfailed. - Creation of the
LogLayerfailed.
§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_logsfunction. Anylogrecords emitted will be converting intotracingevents, and therefore any external functionality that deals withlogrecords 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.