tracing-plus

Crates.iotracing-plus
lib.rstracing-plus
version0.1.8
created_at2025-07-08 09:30:54.660603+00
updated_at2025-08-27 06:22:20.461479+00
description对tracing日志库的增强,通过日志配置文件,注册日志
homepage
repositoryhttps://gitee.com/itao007/tracing-plus.git
max_upload_size
id1742355
size75,237
itao (bj-sjt)

documentation

https://docs.rs/tracing-plus

README

该库是对tracing库的增强

在项目的的根目录创建一个文件名为tracing-log.tomltracing-log.yamltracing-log.yml的文件, 该库会根据配置文件动态的注册日志,然后调用init_tracing_log方法即可完成日志的初始化工作

优先级 toml > yaml > yml

示例

# 文件名 tracing-log.toml
# 控制台输出配置
[console]
# 日志级别, 必填(可选值:`error`、`warn`、`info`、`debug`、`trace`)
level = "info"
# 是否打印线程名 默认为 true
thread = true
# 时间格式 默认为 "%Y-%m-%d %H:%M:%S"
format = "%Y-%m-%d %H:%M:%S"
# 是否打印行号  默认为 false
line-number = true

# 文件输出配置
[[file]]
# 日志级别, 必填(可选值:`error`、`warn`、`info`、`debug`、`trace`)
level = "info"
# 是否打印线程名 默认为 true
thread = true
# 时间格式 默认为 "%Y-%m-%d %H:%M:%S"
format = "%Y-%m-%d %H:%M:%S"
# 是否打印行号 默认为 false
line-number = true
# 保留的最大文件数量 默认为 30
max-files = 60
# 日志文件滚动的固定时间段,可选值: "minutely"、"hourly"、"daily"、"never", 默认值为: "daily"
rotation = "daily"
# 生成的文件名前缀, 必填
prefix = "info"
# 生成的文件名后缀, 默认值为: "log"
suffix = "log"
# 生成的文件所在目录前缀, 默认值为: "logs"
directory = "logs"
# 只记录`target`指定的值的日志 (不配置,则记录全部)
target = "abc"

[[file]]
level = "error"
thread = false
format = "%Y-%m-%d %H:%M:%S"
line-number = true
max-files = 60
rotation = "daily"
prefix = "error"
directory = "logs"

[[file]]
level = "worker"
thread = false
format = "%Y-%m-%d %H:%M:%S"
line-number = true
max-files = 60
rotation = "daily"
prefix = "error"
directory = "logs"
target = "worker"
Commit count: 0

cargo fmt