Skip to main content

try_logf

Function try_logf 

Source
pub fn try_logf(level: DebugLevel, category: &str, args: Arguments<'_>) -> bool
Expand description

Write one line to the debug log without ever blocking. Returns whether it was written.

Every other entry point takes the logger mutex unconditionally, and parking_lot::Mutex is not reentrant: a panic raised while that lock is held hangs any hook that then tries to log — the failure mode documented in src/session/crash_guard.rs. This drops the line instead of hanging. It also never initializes the logger, because re-entering OnceLock::get_or_init on the same thread is its own deadlock.

Two deliberate differences from logf:

  • DEBUG_LEVEL does not filter the message. The callers this exists for are reporting a fault, not tracing, and at the default DEBUG_LEVEL=0 a filtered write would produce nothing at all.
  • Nothing is mirrored to stderr. A panic hook’s stderr output is already written by the default hook it chains to.