Expand description
The tracing
module provides functionalities for setting up and configuring logging.
It includes structures and functions to create and manage various logging layers: stdout,
file, or journald. The module’s primary entry point is the Tracer
struct, which can be
configured to use different logging formats and destinations. If no layer is specified, it will
default to stdout.
§Examples
Basic usage:
use reth_tracing::{
LayerInfo, RethTracer, Tracer,
tracing::level_filters::LevelFilter,
LogFormat,
};
fn main() -> eyre::Result<()> {
let tracer = RethTracer::new().with_stdout(LayerInfo::new(
LogFormat::Json,
LevelFilter::INFO.to_string(),
"debug".to_string(),
None,
));
tracer.init()?;
// Your application logic here
Ok(())
}
This example sets up a tracer with JSON format logging for journald and terminal-friendly format for file logging.
Re-exports§
pub use tracing;
pub use tracing_appender;
pub use tracing_subscriber;
Structs§
- Holds configuration information for file logging.
- Configuration for a logging layer.
- Tracer for application logging.
- Initializes a tracing subscriber for tests.
Enums§
- Represents the logging format.
Traits§
- Trait defining a general interface for logging configuration.
Functions§
- Initializes a tracing subscriber for tests.
Type Aliases§
- A worker guard returned by the file layer.