Skip to main content

log_state_change

Function log_state_change 

Source
pub fn log_state_change(flag: &AtomicBool, new_state: bool) -> bool
Expand description

Log on state transition only. Returns true if state changed.

Use for sustained conditions: memory pressure, circuit breaker, disk full. Log the transition, not every check cycle.

§Example

use std::sync::atomic::AtomicBool;
use hyperi_rustlib::logger::log_state_change;

static PRESSURE_HIGH: AtomicBool = AtomicBool::new(false);
if log_state_change(&PRESSURE_HIGH, true) {
    // Only logs once when transitioning to high
}