#log #libary #configurable #log-file #console-log #hours #message

Logging4Dummys

一个易于使用且高度可配置的日志库

3 个稳定版本

1.0.2 2022年11月27日
0.1.3 2022年11月27日
0.1.2 2022年11月27日
0.1.1 2022年11月27日
0.1.0 2022年11月27日

#15 in #console-log

每月28次下载

GPL-2.0-only

10KB
167 代码行,不包括注释

Logging4Dummys

配置

配置构建方式如下

application_version = '' //Here comes the Version of the Current application in
application_name = '' //This is the name of the application
formatting = 'y/m/d h:M:s l'
//in this format y is the Year m is the Month d is the Day h is the Hour M is the Minute s is the Second and l is the logging Message
stdout = 'log'
//This defines where the Log is written to there are 3 Options: console, this logs the to the console, log, this logs into an log.log file, and both this
// logs into the console as well as into the log.log file

如何记录日志?

您需要调用 Fn() log() 这个 Fn() 函数接受两个参数,第一个是枚举 Log,通过这个枚举您可以指定这是一个信息、警告还是错误,作为第二个参数您需要一个字符串

示例

use Logging4Dummys as log;
fn main() -> (){
     log::Log(log::Log::Info, "This is an Info".to_string());
     // Some Code
 }

此示例将记录 "这是一个信息" 作为信息

依赖项

~1.4–2.3MB
~43K SLoC