🛈 Note: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem.

For the release documentation, please see docs.rs, instead.

tracing

Macro span_enabled

source
macro_rules! span_enabled {
    ($($rest:tt)*) => { ... };
}
Expand description

Tests whether a span with the specified level and target would be enabled.

This is similar to enabled!, but queries the current collector specifically for an event, whereas enabled! queries for an event or span.

See the documentation for [enabled!] for more details on using this macro. See also span_enabled!.

ยงExamples

if span_enabled!(target: "my_crate", Level::DEBUG) {
    // some expensive work...
}
// simpler
if span_enabled!(Level::DEBUG) {
    // some expensive work...
}
// with fields
if span_enabled!(Level::DEBUG, foo_field) {
    // some expensive work...
}