Releases: donnie4w/tklog
Releases · donnie4w/tklog
v0.1.0
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
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