tklog是rust高性能结构化日志库,支持同步日志,异步日志,支持自定义日志的输出格式,支持按时间,按文件大小分割日志文件,支持日志文件压缩备份,支持官方日志库标准API,支持mod独立参数设置,支持日志level独立参数设置
两者方式可以设置
set_cutmode_by_mixed
set_option
一. 调用 .set_cutmode_by_mixed() 函数,参数:
#[test] fn testlog() { LOG.set_cutmode_by_mixed("tklogs.log", 1 << 15,tklog::MODE::HOUR, 10, false); trace!("trace!", "this is sync log"); debug!("debug!", "this is sync log"); info!("info!", "this is sync log"); warn!("warn!", "this is sync log"); error!("error!", "this is sync log"); fatal!("fata!", "this is sync log"); thread::sleep(Duration::from_secs(3)) }
二. 调用 .set_option() 函数
#[test] fn testlog2() { let mut lo = tklog::LogOption::new(); lo.set_fileoption(tklog::handle::FileMixedMode::new("tklogs.log", 1 << 15,tklog::MODE::DAY, 10, false)); LOG.set_option(lo); trace!("trace!", "this is sync log"); debug!("debug!", "this is sync log"); info!("info!", "this is sync log"); warn!("warn!", "this is sync log"); error!("error!", "this is sync log"); fatal!("fata!", "this is sync log"); thread::sleep(Duration::from_secs(3)) }
日志文件切分的结果:
评论删除后,数据将无法恢复
Rust 日志库 tklog 0.2.9 — 支持混合时间文件大小备份模式
v0.2.9 更新内容
两者方式可以设置
set_cutmode_by_mixed设置set_option设置一. 调用 .set_cutmode_by_mixed() 函数,参数:
二. 调用 .set_option() 函数
日志文件切分的结果: