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§
- Ansi
Stripper - Strip ANSI control sequences.
- Append
Count - Append a number when rotating the file. The greater the number, the older. The oldest files are deleted.
- Append
Timestamp - Append current timestamp as suffix when rotating files. If the timestamp already exists, an additional number is appended.
- Dual
Writer - A best-effort writer that supports multiple sub-writers.
- FmtSubscriber
- A
Subscriberthat logs formatted representations oftracingevents. - Quadruple
Writer - A best-effort writer that supports multiple sub-writers.
- Quintuple
Writer - A best-effort writer that supports multiple sub-writers.
- Rotating
File - A rotating log file. This will create log files that are limited in size,
before being moved to
name.Xand optionally compressed. - Triple
Writer - A best-effort writer that supports multiple sub-writers.
Enums§
- Compression
- Compression mode - when to compress files.
- Content
Limit - When to move files: Condition on which a file is rotated.