Skip to main content

colorize_log_line

Function colorize_log_line 

Source
pub fn colorize_log_line(level: LogLevel, message: &str) -> String
Expand description

ANSI-colorize a log line by severity for console output. Always applied at the producer side — every console emission of a log entry runs through this so DBG/INF/WRN/ERR are visually distinct without the operator having to squint at message bodies. Falls through to the bare message when stderr isn’t a TTY or NO_COLOR is set (per use_color); pipeline captures stay readable.