tracing-assert-macros 0.1.4

A macro for capturing trace logs
Documentation

tracing-assert-macros

The tracing_capture_event_fields! macro

This macro runs a given block of code, and returns only the Field/Value tuples emitted per Event.

It's a quick way to inspect the custom data your events carry.

Example usage:

use tracing_assert_macros::tracing_capture_event_fields;
use tracing;

// Given
fn method_under_test() {
    tracing::trace!(message = "something important!");
    tracing::trace!(message = "something else important!");
}
let expected_events: Vec<Vec<(String, String) > > = vec![
    vec![("message".into(), "something important!".into())],
    vec![("message".into(), "something else important!".into())],
];

// When capturing the event field/values into the `events` variable
let events = tracing_capture_event_fields!({
    method_under_test();
});

// Then
assert_eq!(events, expected_events);