#[non_exhaustive]pub enum ColorChoice {
Auto,
Always,
Never,
}human and std only.Expand description
When to colour HumanFormat output.
Resolved once, when a sink is built, into a plain on/off setting
for HumanFormat::color.
§Examples
use log_io::format::{ColorChoice, HumanFormat};
let fmt = HumanFormat::new().color(ColorChoice::Auto.enabled_for_stderr());
assert!(ColorChoice::Always.resolve(false));
assert!(!ColorChoice::Never.resolve(true));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Auto
Colour when the destination is a terminal, honouring the conventional environment variables:
NO_COLORset to a non-empty value disables colour;CLICOLOR_FORCEset to a non-empty value other than0enables colour even when not a terminal;TERM=dumbdisables colour.
On Windows, colour is only enabled automatically inside
terminals known to interpret ANSI sequences without extra setup
(Windows Terminal, ConEmu, or any environment that sets TERM,
such as Git Bash or MSYS2). The classic console host needs the
virtual-terminal mode switched on through the Windows API, which
this crate does not do because it forbids unsafe code; use
ColorChoice::Always if your program enables that mode itself.
Always
Always colour.
Never
Never colour.
Implementations§
Source§impl ColorChoice
impl ColorChoice
Sourcepub fn resolve(self, is_terminal: bool) -> bool
pub fn resolve(self, is_terminal: bool) -> bool
Resolve against an explicit “is the destination a terminal” answer and the process environment.
Sourcepub fn enabled_for_stdout(self) -> bool
pub fn enabled_for_stdout(self) -> bool
Resolve for the process’s standard output.
Sourcepub fn enabled_for_stderr(self) -> bool
pub fn enabled_for_stderr(self) -> bool
Resolve for the process’s standard error.