diff_logger

Crates.iodiff_logger
lib.rsdiff_logger
version0.1.0
sourcesrc
created_at2023-04-10 18:38:31.399483
updated_at2023-04-10 18:38:31.399483
descriptionPretty diff logger for JSON values in rust
homepage
repositoryhttps://github.com/nalchevanidze/diff_logger
max_upload_size
id835352
size102,231
David Nalchevanidze (nalchevanidze)

documentation

README

DiffLogger

generates a log of changes for JSON values

Example

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": "david1@email.com"},
        ]
    });

    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": "John@email.com"},
        ]
    });

    println!("----------------------\n");
    logger.log_diff(&prev, &next);
    println!("\n----------------------");
}

logs:

demo

Commit count: 24

cargo fmt