log-ndc

log extension with NDC-like functionality

2 unstable releases

✓ Uses Rust 2018 edition

0.2.0 Feb 7, 2019
0.1.0 Feb 3, 2019

#84 in #logging

Download history 16/week @ 2019-01-30

8 downloads per month
Used in 1 crate

MIT/Apache

5KB
144 lines

log crate extension with NDC-like functionality

Build Status License crates.io

This crate allows settings a thread-local variable and crate prepends in in ndc_* macros. E. g.

ndc_warn!("something happened"); // works exactly like `log!` macro

log_ndc::set(format!("reqid={}", 10));

ndc_info!("starting request");
// outputs
// INFO 2019-02-03T23:51:26Z: mycrate: [reqid=10] starting request

warn!("something bad happened"); // this line does not output NDC information

This crate depends on log crate, not replaces it.

This crate is fully compatible with log-formatting crates like env_logger.

Regular trace!(...)...error!(...) macros still work but do not output NDC information.

The word "NDC" is taken from log4j, it means "nested dianostics context".

Dependencies

~57KB