custom_colors/
custom_colors.rs

1#[cfg(all(feature = "termcolor", not(feature = "paris")))]
2use log::*;
3#[cfg(feature = "termcolor")]
4use simplelog::*;
5
6#[cfg(feature = "termcolor")]
7fn main() {
8    let config = ConfigBuilder::new()
9        .set_level_color(Level::Error, Some(Color::Magenta))
10        .set_level_color(Level::Trace, Some(Color::Green))
11        .build();
12
13    TermLogger::init(
14        LevelFilter::Trace,
15        config,
16        TerminalMode::Stdout,
17        ColorChoice::Auto,
18    )
19    .unwrap();
20    error!("Magenta error");
21    warn!("Yellow warning");
22    info!("Blue info");
23    debug!("Cyan debug");
24    trace!("Green trace");
25}
26
27#[cfg(not(feature = "termcolor"))]
28fn main() {
29    println!("this example requires the termcolor feature.");
30}