Trait Tracer

Source
pub trait Tracer: Sized {
    // Required method
    fn init_with_layers(self, layers: Layers) -> Result<Option<WorkerGuard>>;

    // Provided method
    fn init(self) -> Result<Option<WorkerGuard>> { ... }
}
Expand description

Trait defining a general interface for logging configuration.

The Tracer trait provides a standardized way to initialize logging configurations in an application. Implementations of this trait can specify different logging setups, such as standard output logging, file logging, journald logging, or custom logging configurations tailored for specific environments (like testing).

Required Methods§

Source

fn init_with_layers(self, layers: Layers) -> Result<Option<WorkerGuard>>

Initialize the logging configuration with additional custom layers.

This method allows for more customized setup by accepting pre-configured Layers which can be further customized before initialization.

§Arguments
  • layers - Pre-configured Layers instance to use for initialization
§Returns

An eyre::Result which is Ok with an optional WorkerGuard if a file layer is used, or an Err in case of an error during initialization.

Provided Methods§

Source

fn init(self) -> Result<Option<WorkerGuard>>

Initialize the logging configuration.

By default, this method creates a new Layers instance and delegates to init_with_layers.

§Returns

An eyre::Result which is Ok with an optional WorkerGuard if a file layer is used, or an Err in case of an error during initialization.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§