tracing-assert-macros

Crates.iotracing-assert-macros
lib.rstracing-assert-macros
version0.1.4
sourcesrc
created_at2023-02-21 17:57:05.96592
updated_at2023-02-21 19:18:56.361392
descriptionA macro for capturing trace logs
homepage
repository
max_upload_size
id790928
size18,863
(Xandkeeper)

documentation

README

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);
Commit count: 0

cargo fmt