Skip to content

Releases: donnie4w/tklog

v0.2.6

04 Nov 05:16
Compare
Choose a tag to compare

version 0.2.6

修复时间分割的bug

说明:旧版本在时间分割时,没有判断大单位时间,存在bug,该版本已经修复

v0.2.5

31 Oct 02:35
Compare
Choose a tag to compare

version 0.2.5

update:

  1. ADD RUST_LOG
    • RUST_LOG is an environment variable used to control the logging levels in Rust applications.
  2. Optimize performance

v0.2.4

21 Oct 12:53
Compare
Choose a tag to compare

version 0.2.4
更新内容

v0.2.3

18 Oct 02:14
Compare
Choose a tag to compare

version 0.2.3
版本更新

v0.2.2

09 Oct 03:16
Compare
Choose a tag to compare

version0.2.2
更新内容

v0.2.1

30 Sep 06:45
Compare
Choose a tag to compare

version0.2.1
更新内容

v0.2.0

07 Sep 03:53
Compare
Choose a tag to compare

增加支持日志级别设置独立日志格式参数,设置日志文件

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))
}

示例说明:

  1. Info级别的文件日志设置为按天分隔,文件名 0200time.log
  2. Fatal级别的文件日志设置为按大小分隔,文件名 0200size.log

v0.1.0

26 Aug 03:08
Compare
Choose a tag to compare

Add:

tklog Supports Independent Logging Format Parameters for Log Levels

tklog Independent Logging Format Parameters for Log Levels via set_level_option()
#[test]
fn testlog() {
    // Set the log format for Info level to include Format::LevelFlag.
    // Set the log format for Fatal level to include Format::LevelFlag and 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))
}

Execution Result

---- 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

v0.0.10

15 Aug 06:46
Compare
Choose a tag to compare

release 0.0.10

增加支持自定义日志多参数分隔符函数 set_separator

tklog allows setting custom separators using the set_separator() method
the following Rust code demonstrates how to configure and use custom separators for log entries in the tklog framework:
#[test]
fn testlog() {
    log_init();
    trace!("trace>>>>", "aaaaaaaaa", 1, 2, 3, 4);
    debug!("debug>>>>", "bbbbbbbbb", 1, 2, 3, 5);
    LOG.set_separator("|");  //设置参数分隔符 | 
    info!("info>>>>", "ccccccccc", 1, 2, 3, 5);
    warn!("warn>>>>", "dddddddddd", 1, 2, 3, 6);
    LOG.set_separator(","); //设置参数分隔符 ,
    error!("error>>>>", "eeeeeeee", 1, 2, 3, 7);
    fatal!("fatal>>>>", "ffffffff", 1, 2, 3, 8);
    thread::sleep(Duration::from_secs(1))
}
Execution Result

The output generated by the testlog function demonstrates the impact of setting different separators on the log messages:

---- testlog stdout ----
[TRACE] 2024-08-15 14:14:19.289590 tests\testsynclog.rs 22:trace>>>>aaaaaaaaa1234
[DEBUG] 2024-08-15 14:14:19.289744 tests\testsynclog.rs 23:debug>>>>bbbbbbbbb1235
[INFO] 2024-08-15 14:14:19.289761 tests\testsynclog.rs 25:info>>>>|ccccccccc|1|2|3|5
[WARN] 2024-08-15 14:14:19.289774 tests\testsynclog.rs 26:warn>>>>|dddddddddd|1|2|3|6
[ERROR] 2024-08-15 14:14:19.289789 tests\testsynclog.rs 28:error>>>>,eeeeeeee,1,2,3,7
[FATAL] 2024-08-15 14:14:19.289802 tests\testsynclog.rs 29:fatal>>>>,ffffffff,1,2,3,8

v0.0.9

07 Aug 01:14
Compare
Choose a tag to compare

New features in this release

  • supports custom log processing functions.
  • tklog allows the addition of external custom functions through set_custom_handler(), enabling control over the log processing flow and logic.