Crate tracing_subscriber_multi

Crate tracing_subscriber_multi 

Source
Expand description

§tracing-subscriber-multi

Write tracing logs with helpful writer proxies, including:

  • Writing to multiple places
  • Writing to rotating log files
  • Stripping ANSI sequences for a single writer

§Example

use tracing_subscriber_multi::*;

let subscriber = FmtSubscriber::builder()
    .with_max_level(tracing::Level::TRACE)
    .with_ansi(true)
    .with_writer(std::sync::Mutex::new(DualWriter::new(
        std::io::stderr(),
        AnsiStripper::new(RotatingFile::new(
            "program.log",
            AppendCount::new(3),
            ContentLimit::Lines(1000),
            Compression::OnRotate(0),
        )),
    )))
    .finish();
tracing::subscriber::set_global_default(subscriber).expect("failed to initialise logger");

Structs§

AnsiStripper
Strip ANSI control sequences.
AppendCount
Append a number when rotating the file. The greater the number, the older. The oldest files are deleted.
AppendTimestamp
Append current timestamp as suffix when rotating files. If the timestamp already exists, an additional number is appended.
DualWriter
A best-effort writer that supports multiple sub-writers.
FmtSubscriber
A Subscriber that logs formatted representations of tracing events.
QuadrupleWriter
A best-effort writer that supports multiple sub-writers.
QuintupleWriter
A best-effort writer that supports multiple sub-writers.
RotatingFile
A rotating log file. This will create log files that are limited in size, before being moved to name.X and optionally compressed.
TripleWriter
A best-effort writer that supports multiple sub-writers.

Enums§

Compression
Compression mode - when to compress files.
ContentLimit
When to move files: Condition on which a file is rotated.