Skip to main content

test_traced

Attribute Macro test_traced 

Source
#[test_traced]
Expand description

Capture logs from a test run using libtest’s output capture functionality.

The default log level is DEBUG, but can be overridden with the macro argument or the RUST_LOG environment variable. When RUST_LOG is set, it takes precedence over the macro argument, enabling per-module filtering (e.g., RUST_LOG=commonware_consensus=trace,warn).

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

§Example

use tracing::{debug, info};

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