Rust 日志库 tklog v0.2.0 :支持设置日志级别独立日志文件
tklog是rust高性能结构化日志库,支持同步日志,异步日志,支持自定义日志的输出格式,支持按时间,按文件大小分割日志文件,支持日志文件压缩备份,支持官方日志库标准API,支持mod独立参数设置,支持日志level独立参数设置
v0.2.0 版本更新
tklog 支持日志级别所有独立参数设置
- tklog 通过 set_level_option() 设置日志级别的独立日志参数
- set_level_option() 接收任意实现 OptionTrait特征的对象
示例1 :参数 LevelOption
对象,可以设置日志格式化输出
#[test] fn testlog() { //将Info级别的日志格式设置为 Format::LevelFlag //将Fatal级别的日志格式设置为 Format::LevelFlag | Format::Date LOG.set_level_option(LEVEL::Info, LevelOption { format: Some(Format::LevelFlag), formatter: None }) .set_level_option(LEVEL::Fatal, LevelOption { format: Some(Format::LevelFlag | Format::Date), formatter: None}); trace!("this is trace log"); debug!("this is debug log"); info!("this is info log"); warn!("this is warn log"); error!("this is error log"); fatal!("this is fatal log"); thread::sleep(Duration::from_secs(1)) }
执行结果
---- testlog stdout ---- [DEBUG] 2024-08-24 15:06:02 test_0100.rs 17:this is debug log [INFO] this is info log [WARN] 2024-08-24 15:06:02 test_0100.rs 19:this is warn log [ERROR] 2024-08-24 15:06:02 test_0100.rs 20:this is error log [FATAL] 2024-08-24 this is fatal log
示例2 参数 LogOption
对象,可以设置更多参数,包括设置日志文件
#[test] fn testlog() { LOG.set_level_option(LEVEL::Info, LogOption { format: Some(Format::LevelFlag), formatter: None, level:None, console: None, fileoption: Some(Box::new(FileTimeMode::new("0200time.log", tklog::MODE::DAY, 0, false))) }) .set_level_option(LEVEL::Fatal, LogOption { format: Some(Format::LevelFlag | Format::Date), formatter: None, level: None, console: None, fileoption: Some(Box::new(FileSizeMode::new("0200size.log", 1<<10, 0, false)))}); trace!("this is trace log"); debug!("this is debug log"); info!("this is info log"); warn!("this is warn log"); error!("this is error log"); fatal!("this is fatal log"); thread::sleep(Duration::from_secs(1)) }
示例说明:
- Info级别的文件日志设置为按天分割,文件名
0200time.log
- Fatal级别的文件日志设置为按大小分割,文件名
0200size.log
0.2.0版本基准压力测试
说明:
- log_benchmakk: tklog 常规打印压力测试
- mod_benchmark: mod 模块独立日志文件压力测试
- level_benchmark : level 日志级别的独立日志文件压力测试
结论:
- 模块独立日志文件打印,日志级别的独立日志文件打印 与常规日志文件打印的效率基本一致,没有明显的差异。
- 模块独立日志文件设置为 0.0.8 版本新增的功能。

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
别再 mybatis 了,融合 JPA 和超强查询的 sqltoy-orm 5.6.22 发版
开源地址: github:https://github.com/sagframe/sagacity-sqltoy gitee:https://gitee.com/sagacity/sagacity-sqltoy idea 插件 (可直接在 idea 中检索安装):https://github.com/imyuyu/sqltoy-idea-plugin sqltoy 脚手架项目:https://gitee.com/momoljw/sss-rbac-admin sqltoy lambda 项目:https://gitee.com/gzghde/sqltoy-plus 更新内容(5.6.19~5.6.22) 1、修复同比环比计算中除数跟零的对比缺陷(BigDeciaml("0.00") 不等于BigDeciaml.ZERO)(5.6.22) 2、修复跨数据库适配Nvl函数,排除coalesce匹配,coalesce各种数据库都支持且非单纯的ifnull/nvl逻辑(5.6.21) 3、修复单个查询封装成非POJO对象层级关系时,未设置notNullField的缺陷(5.6.20) 4、pos...
- 下一篇
Xinference v0.15.0 版本飞跃:自定义模型能力再升级,重塑 AI 交互体验
Xorbits Inference(Xinference)是一个 性能强大且功能全面的 分布式 推理框架。可用于大语言模型(LLM),语音识别模型,多模态模型等各种模型的推理。通过 Xorbits Inference,你可以轻松地 一键部署你自己的模型或内置的前沿开源模型 - https://github.com/xorbitsai/inference。无论你是研究者,开发者,或是数据科学家,都可以通过 Xorbits Inference 与最前沿的 AI 模型,发掘更多可能。 Xinference 的功能和亮点有: * 🌟 模型推理,轻而易举:大语言模型,语音识别模型,多模态模型的部署流程被大大简化。一个命令即可完成模型的部署工作。 * ⚡️ 前沿模型,应有尽有:框架内置众多中英文的前沿大语言模型,包括 baichuan,chatglm2 等,一键即可体验!内置模型列表还在快速更新中! * 🖥 异构硬件,快如闪电:通过 ggml,同时使用你的 GPU 与 CPU 进行推理,降低延迟,提高吞吐! * ⚙️ 接口调用,灵活多样:提供多种使用模型的接口,包括 OpenAI 兼容的 R...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- 2048小游戏-低调大师作品
- Windows10,CentOS7,CentOS8安装MongoDB4.0.16
- SpringBoot2全家桶,快速入门学习开发网站教程
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- Eclipse初始化配置,告别卡顿、闪退、编译时间过长
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- SpringBoot2更换Tomcat为Jetty,小型站点的福音
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- CentOS7,8上快速安装Gitea,搭建Git服务器
- CentOS6,CentOS7官方镜像安装Oracle11G