Skip to main content

use_color

Function use_color 

Source
pub fn use_color() -> bool
Expand description

Log a diagnostic message through the global observer and append to the async log sink (if initialized). Safe to call from anywhere — falls back to stderr if no observer is set.

The file write is non-blocking: the line is enqueued onto a bounded channel consumed by the dedicated log-sink thread. On overflow the line is dropped and the sink’s dropped_count is bumped — never blocks the caller, even on a stalled disk. Whether ANSI color escapes are appropriate for stderr. true only when stderr is a TTY and the operator hasn’t disabled color via the conventional NO_COLOR env var (https://no-color.org). Pipelined / CI contexts return false so log archives stay readable. Cached on first call; the answer doesn’t change over a process’s lifetime.