context-logger 0.2.0

A small structured context propagation layer for the standard Rust log ecosystem.
Documentation
// Warning: Because each test initializes the logger, we need to split the
// tests into separate files to avoid multiple initializations of the logger.

use context_logger::{LogContext, LogScope};

use crate::common::{LogRecordExt as _, check_logger_once};

pub mod common;

#[test]
fn test_smoke() {
    check_logger_once(
        |logger| logger,
        |entry| {
            let val = entry.get_field("answer").unwrap();
            assert_eq!(val, 42);
            Ok(())
        },
    );

    let _guard = LogScope::enter(LogContext::new().with_local_field("answer", 42));
    log::info!("Smoke on the water, fire in the sky");
}