Drakulix / simplelog.rs

Simple Logging Facility for Rust
https://docs.rs/simplelog/
Apache License 2.0
414 stars 71 forks source link

add `TimePadding` with `Right` and `AddZeros` #134

Open cscherrNT opened 12 months ago

cscherrNT commented 12 months ago

This is a proposed fix for #133.

I added a TimePadding Enum. in write_time, the formatted time stamp is generated with the time module like before, then I do some formatting.

Usage

Build a Config like this:

                let conf = conf_builder
                    .set_location_level(elem)
                    .set_target_level(elem)
                    .set_max_level(elem)
                    .set_time_level(elem)
                    .set_time_format_rfc3339()
                    .set_time_padding(config::TimePadding::AddZeros)
                    .build();

Example output:

2023-08-02T08:08:45.217511363Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217519856Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217590429Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217599035Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217624283Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217628916Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217652289Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217656130Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217680170Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217684238Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217714112Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217717736Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217741200Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217782376Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217815202Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217819815Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217886072Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information
2023-08-02T08:08:45.217891502Z [INFO] simplelog::tests: [src/lib.rs:238] Test Information

Note: This is my first Pull Request, I hope I didn't miss anything important.