3 个不稳定版本
0.2.0 | 2020 年 10 月 27 日 |
---|---|
0.1.1 | 2019 年 8 月 10 日 |
0.1.0 | 2019 年 8 月 4 日 |
#10 in #log4rs
9KB
168 行
log4rs-cases
模块,方便地使用 log4rs。
用法
fn main() {
// 1. setting to rotate log files by size.
let setting = rotate::size::SettingBuilder::new()
.file_path("sample/sample.log")
.file_pattern("backup/sample.{}.log")
.build();
// 2. create log4rs Config.
let config = setting.configure().unwrap();
// 3. call init_config() as usual.
log4rs::init_config(config).unwrap();
let greeting = "hello, world!";
debug!("debug: {}", greeting);
info!("info: {}", greeting);
warn!("warn: {}", greeting);
error!("error: {}", greeting);
}
输出
$ tail -f sample/sample.log
2019-08-10T16:59:36.011987+09:00 [DEBUG] sample_app debug: hello, world!
2019-08-10T16:59:36.012626+09:00 [INFO] sample_app info: hello, world!
2019-08-10T16:59:36.012680+09:00 [WARN] sample_app warn: hello, world!
2019-08-10T16:59:36.012731+09:00 [ERROR] sample_app error: hello, world!
依赖
~520KB