rust-cli / env_logger

A logging implementation for `log` which is configured via an environment variable.
https://docs.rs/env_logger
Apache License 2.0
797 stars 124 forks source link

How to forcibly color output even when the output is not a terminal? #258

Closed your-diary closed 1 year ago

your-diary commented 1 year ago

Many UNIX commands have the option --color {auto|always|never}, and --color always always outputs colored result even when the destination is not a terminal.

In a similar manner, in env_logger, how to forcibly color output even when the output is not a terminal? In other words, I'd like to optionally disable terminal detection.

miraclx commented 1 year ago
fn main() {
    env_logger::builder()
        .write_style(WriteStyle::Always)
        .init();
}

or

RUST_LOG_STYLE=always ./app
your-diary commented 1 year ago

@miraclx Both worked like a charm. Thank you.