commonware_macros

Attribute Macro test_with_logging

source
#[test_with_logging]
Expand description

Capture logs (based on the provided log level) from a test run using libtest’s output capture functionality. This macro defaults to a log level of DEBUG if no level is provided.

This macro is powered by the tracing and tracing-subscriber crates.

§Example

use commonware_macros::test_with_logging;
use tracing::{debug, info};

#[test_with_logging("INFO")]
fn test_info_level() {
    info!("This is an info log");
    debug!("This is a debug log (won't be shown)");
    assert_eq!(2 + 2, 4);
}