Skip to main content

detlog_observed

Macro detlog_observed 

Source
macro_rules! detlog_observed {
    () => { ... };
}
Expand description

Whether a detlog! record emitted at this point would reach anything.

WHY THIS IS NEEDED, and why it is a macro rather than a function.

detlog! routes to the process-local forwarder when one is installed and its policy takes the calling module’s records, and to tracing::info! otherwise. tracing does not evaluate a macro’s value expressions when the level is disabled, so work done inside a detlog! argument is already free when nothing observes the record. Work done before the macro is not, and callers that must prepare something expensive to pass in have no way to know they can skip it.

tracing’s level check is per-callsite and keyed on the calling module’s target, so this has to expand at the caller rather than resolve inside detcore::detlog; otherwise a target-scoped filter could enable one and disable the other.

Use it only to skip preparatory work. It is not a substitute for detlog!’s own gating, and a caller that guards a record with it must still emit that record through detlog!.