Function tracing_capture::predicates::message
source · pub fn message<P: Predicate<str>>(matches: P) -> MessagePredicate<P>
Expand description
Creates a predicate for the message of a CapturedEvent
.
§Arguments
The argument of this function is a str
predicate for the event message.
§Examples
let storage = SharedStorage::default();
let subscriber = Registry::default().with(CaptureLayer::new(&storage));
tracing::subscriber::with_default(subscriber, || {
tracing::info_span!("compute").in_scope(|| {
tracing::info!(result = 42, "computations completed");
});
});
let storage = storage.lock();
// All of these access the single captured event.
let events = storage.scan_events();
let _ = events.single(&message(eq("computations completed")));
let _ = events.single(&message(contains("completed")));