Macro tracing::event_enabled

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

Tests whether an event 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.

Although it shares the name, this does not call Collect::event_enabled. Collect::event_enabled is only called once the event fields are available.

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

§Examples

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