Expand description
§Secra Logger
一个生产级的 Rust 日志系统库,基于 tracing 生态系统构建。
§特性
- ✅ 基于 tracing 生态,支持结构化日志
- ✅ JSON 格式输出(基于 bunyan formatter)
- ✅ 支持控制台、文件、或同时输出
- ✅ 按文件大小滚动
- ✅ 按日期分目录(YYYY-MM-DD)
- ✅ 可配置文件保留策略
- ✅ 线程安全
- ✅ 支持 log crate 桥接
- ✅ 支持 actix-web 集成
§快速开始
use secra_logger::{init_logger, LoggerConfig, LogOutput};
use tracing::Level;
let config = LoggerConfig::new(
Level::INFO,
LogOutput::Both,
"./logs/app.log",
10 * 1024 * 1024, // 10MB
Some(10), // 最多保留 10 个文件
"myapp",
);
init_logger(config).unwrap();
tracing::info!("应用启动");Re-exports§
pub use config::LogOutput;pub use config::LoggerConfig;pub use error::LoggerError;pub use error::Result;pub use init::init_logger;pub use tracing;
Modules§
Structs§
- Level
- Describes the level of verbosity of a span or event.