Crate reth_tracing

Source
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§

FileInfo
Holds configuration information for file logging.
LayerInfo
Configuration for a logging layer.
RethTracer
Tracer for application logging.
TestTracer
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§

FileWorkerGuard
A worker guard returned by the file layer.