tracing-rolling-file
A rolling file appender with customizable rolling conditions, based on rolling-file. Includes built-in support for rolling conditions on date/time (daily, hourly, every minute) and/or size.
Follows a Debian-style naming convention for logfiles, using basename, basename.1, ..., basename.N where N is the maximum number of allowed historical logfiles.
This is useful to combine with the tracing crate and tracing_appender::non_blocking::NonBlocking -- use it as an alternative to tracing_appender::rolling::RollingFileAppender.
Examples
use *;
let file_appender = new.unwrap;
Builder
To simplify the creation of a RollingFileAppenderBase
, an instance can be built as per the example below.
use *;
let builder = builder;
let appender = builder
.filename
.max_filecount
.condition_max_file_size
.build
.unwrap;
Non-blocking support
To combine the tracing_appender::non_blocking::NonBlocking
functionality, the feature needs to be enabled in Cargo.toml, i.e.
[]
= { = "0.1.3", = ["non-blocking"] }
Once enabled, you can use the method get_non_blocking_appender
to generate
a non-blocking version of the RollingFileAppenderBase.
use *;
let file_appender = new?;
let = file_appender.get_non_blocking_appender;
Development
Must pass latest stable clippy, be formatted with nightly rustfmt, and pass unit tests:
cargo +nightly fmt
cargo clippy --all-targets
cargo test
License
Dual-licensed under the terms of either the MIT license or the Apache 2.0 license.