Crates.io | tracing-assert-macros |
lib.rs | tracing-assert-macros |
version | 0.1.4 |
source | src |
created_at | 2023-02-21 17:57:05.96592 |
updated_at | 2023-02-21 19:18:56.361392 |
description | A macro for capturing trace logs |
homepage | |
repository | |
max_upload_size | |
id | 790928 |
size | 18,863 |
tracing_capture_event_fields!
macroThis 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);