# mlogst **Repository Path**: yangxijing/mlogst ## Basic Information - **Project Name**: mlogst - **Description**: 指定日志存放目录,滚动日志,限制日志目录大小 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-01-31 - **Last Updated**: 2024-12-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # mlogst 指定日志存放目录,滚动日志,限制日志目录大小,超出限制的大小,从最早生成的日志开始删除。 ## example ```rust #[macro_use] extern crate tracing; use mlogst::mlog_init; use std::thread; use std::time::Duration; // 如果大小限制小于程序单个日志文件的大小,会把当前的日志文件删除了,要等到新的时间点触发滚动才会再打印出日志 fn main() { let _guard = mlog_init( "./logs", 32 * 1000, tracing_appender::rolling::Rotation::MINUTELY, ); for i in 0..10 { info!("i: {}", i); warn!("i: {}", i); } loop { error!("count: {}", count); warn!("count: {}", count); info!("count: {}", count); debug!("count: {}", count); trace!("count: {}", count); count += 1; thread::sleep(Duration::from_secs(1)); } } ``` ```bash RUST_LOG=debug cargo run ```