Macro event_enabled

Source
macro_rules! event_enabled {
    ($($rest:tt)*) => { ... };
}
Available on crate feature tracing only.
Expand description

Re-export the tracing crate to have access to tracing macros like info!, debug!, trace! and so on. Tests whether an event with the specified level and target would be enabled.

This is similar to enabled!, but queries the current subscriber 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 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...
}