2个版本
0.1.1 | 2022年4月30日 |
---|---|
0.1.0 | 2022年4月30日 |
#589 in 调试
5KB
log4r
一个用于Rust的极其简单的日志包。
log4r相对于log的主要优势是使用函数而不是宏。这样您可以在clippy.toml
中禁止它们,使其更适合调试。
如何使用
- 首先将crate添加到
Cargo.toml
,在依赖项下添加log4r = 0.1.0
。 - 将
use log4r::*;
添加到文件的顶部。 - 现在您可以这样做:
info(some_info.to_string())
如果只想在开发期间使用这些函数,请将以下内容添加到项目根目录下的clippy.toml
disallowed-methods = [
{ path = "log4r::success", reason = "Logs are not allowed in builds" },
{ path = "log4r::warning", reason = "Logs are not allowed in builds" },
{ path = "log4r::info", reason = "Logs are not allowed in builds" },
{ path = "log4r::error", reason = "Logs are not allowed in builds" },
{ path = "log4r::critical", reason = "Logs are not allowed in builds" },
{ path = "log4r::log", reason = "Logs are not allowed in builds" },
]
当您运行Clippy时,它将报告关于这些函数使用错误/警告。