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§
- File
Info - Holds configuration information for file logging.
- Layer
Info - Configuration for a logging layer.
- Reth
Tracer - Tracer for application logging.
- Test
Tracer - Initializes a tracing subscriber for tests.
Enums§
- LogFormat
- Represents the logging format.
Traits§
- Tracer
- Trait defining a general interface for logging configuration.
Functions§
- init_
test_ tracing - Initializes a tracing subscriber for tests.
Type Aliases§
- File
Worker Guard - A worker guard returned by the file layer.