Crates.io | tracing-assertions |
lib.rs | tracing-assertions |
version | 0.6.0 |
created_at | 2024-08-24 02:08:18.624944+00 |
updated_at | 2024-10-30 20:11:08.171043+00 |
description | An assertions framework for Tokio tracing. |
homepage | |
repository | https://github.com/JonathanWoollett-Light/tracing-assertions |
max_upload_size | |
id | 1349769 |
size | 31,068 |
An assertions framework for tracing.
Simpler and faster than the alternatives.
use tracing_subscriber::layer::SubscriberExt;
// Initialize a subscriber with the layer.
let asserter = tracing_assertions::Layer::default();
let registry = tracing_subscriber::Registry::default();
let subscriber = registry.with(asserter.clone());
let guard = tracing::subscriber::set_default(subscriber);
let one = asserter.matches("one");
let two = asserter.matches("two");
let and = &one & &two;
tracing::info!("one");
one.assert();
tracing::info!("two");
two.assert();
and.assert();
drop(guard); // Drop `subscriber` as the current subscriber.
#[test]
attribute that initializes logging and/or tracing infrastructure before running tests.tracing
.