Function unwind_context::enable_colors_if_supported
source · pub fn enable_colors_if_supported()
Available on crate feature
detect-color-support
only.Expand description
Enables ANSI colors if supported by the terminal for stderr stream for all threads.
It checks for a basic colors support. By default, it enables 16-ANSI-color colorization if the colors have not changed.
This function uses supports-color
crate to detect color support.
supports-color
crate takes the NO_COLOR
and FORCE_COLOR
environment
variables into account as well.
§Examples
use unwind_context::unwind_context;
fn func(foo: u32, bar: &str) {
let _ctx = unwind_context!(fn(foo, bar));
// ...
}
fn main() {
unwind_context::enable_colors_if_supported();
// ...
func(123, "abc");
// ...
}
#[test]
fn test() {
unwind_context::enable_colors_if_supported();
// ...
func(234, "bcd");
// ...
}