1 个不稳定版本
0.1.0 | 2023年4月10日 |
---|
#722 in 调试
87KB
506 代码行
DiffLogger
为 JSON 值生成更改日志
示例
use diff_logger::DiffLogger;
use serde_json::json;
fn main() {
let logger = DiffLogger::new().set_header("timestamp", false);
let prev = json!({
"name": "David",
"age": 43,
"ver": {
"timestamp": "2023-04-07T11:17:50+00:00",
"value": "some text",
},
"state": {
"timestamp": "2023-04-07T11:17:50+00:00",
"removedField": "some text",
"valueChange": 45
},
"email": [
{ "num": "[email protected]"},
]
});
let next = json!(
{
"name": "John",
"age": 35,
"state": {
"timestamp": "2023-04-07T12:17:50+00:00",
"newField": 4,
"valueChange": 42352
},
"ver": {
"timestamp": "2023-04-07T11:18:50+00:00",
"value": "some text",
},
"email": [
{ "num": "[email protected]"},
]
});
println!("----------------------\n");
logger.log_diff(&prev, &next);
println!("\n----------------------");
}
日志
依赖项
~1–12MB
~79K SLoC