5 releases

0.3.3 Apr 24, 2024
0.3.2 Apr 23, 2024
0.3.1 Apr 22, 2024
0.3.0 Apr 22, 2024
0.2.0 Apr 22, 2024

#5 in #detail

Download history 243/week @ 2024-07-24 63/week @ 2024-07-31 67/week @ 2024-08-07 170/week @ 2024-08-14 82/week @ 2024-08-21 112/week @ 2024-08-28 126/week @ 2024-09-04 62/week @ 2024-09-11 74/week @ 2024-09-18 111/week @ 2024-09-25 80/week @ 2024-10-02 22/week @ 2024-10-09 14/week @ 2024-10-16 38/week @ 2024-10-23 98/week @ 2024-10-30 56/week @ 2024-11-06

206 downloads per month

Apache-2.0

16KB
197 lines

detailer

A convenience tool for workflow logging.

About

A trim, low-dependency tool for logging things. This project does not use unsafe code. It only depends on std and log.

Details

Detailer lets you log all your related information about a workflow in one log report. Sometimes you want that. Sometimes you only want that once in a while.

The overhead of a disabled Detailer log line is similar to the overhead of a disabled log level, like a log::debug!() when the current level is set to Info. An enabled detail!() statement costs a writeln!() into a String. If you want to keep this inexpensive and you have a ton of these detailers, you should consider using an explicit flush() and reuse them. Remember to reset() when your time should restart, if you are using timings.

use detailer::{Detailer, detail, new_detailer, scope};

let mut detailer = new_detailer!(); // Info level, WithTimings
detail!(detailer, "some {} message", "log");

You might consider taking a Detailer as a parameter for functions that should log detail when the detailer is enabled. The functions do not need to inspect the Detailer: They only log their details, similarly to how you use log.

fn expensive_work(detailer: &mut Detailer, name: &str) {
    let _guard = scope!(detailer, "expensive work: {name}"); // indent lines under the expensive_work stack
    detail!(detailer, "some part of the work");
    detail!(detailer, "some other part of the work");
}

Dependencies

~87KB