Function tracing_capture::predicates::level
source · pub fn level<P: IntoLevelPredicate>(matches: P) -> LevelPredicate<P::Predicate>
Expand description
Creates a predicate for the [Level
] of a CapturedSpan
or CapturedEvent
.
§Arguments
The argument of this function may be:
- [
Level
]: will be compared exactly - [
LevelFilter
]: will be compared as per ordinary rules - Any
Predicate
for [Level
]. To bypass Rust orphaning rules, the predicate must be enclosed in square brackets (i.e., a one-value array).
§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!(answer = 42, "done");
});
});
let storage = storage.lock();
// All of these access the single captured span.
let spans = storage.scan_spans();
let _ = spans.single(&level(Level::INFO));
let _ = spans.first(&level(LevelFilter::DEBUG));
let _ = spans.last(&level([gt(Level::WARN)]));