Struct fern::colors::ColoredLogLevelConfig [] [src]

#[must_use = "builder methods take config by value and thus must be reassigned to variable"]
pub struct ColoredLogLevelConfig { pub error: Color, pub warn: Color, pub info: Color, pub debug: Color, pub trace: Color, }

Configuration specifying colors a log level can be colored as.

Example usage setting custom 'info' and 'debug' colors:

use fern::colors::{Color, ColoredLogLevelConfig};

let colors = ColoredLogLevelConfig::new()
    .info(Color::Green)
    .debug(Color::Magenta);

fern::Dispatch::new()
    .format(move |out, message, record| {
        out.finish(format_args!(
            "[{}] {}",
            colors.color(record.level()),
            message
        ))
    })
    .chain(std::io::stdout())
    .apply()?;

Fields

The color to color logs with the Error level.

The color to color logs with the Warn level.

The color to color logs with the Info level.

The color to color logs with the Debug level.

The color to color logs with the Trace level.

Methods

impl ColoredLogLevelConfig
[src]

[src]

Creates a new ColoredLogLevelConfig with the default colors.

This matches the behavior of ColoredLogLevelConfig::default.

[src]

Overrides the Error level color with the given color.

The default color is Color::Red.

[src]

Overrides the Warn level color with the given color.

The default color is Color::Yellow.

[src]

Overrides the Info level color with the given color.

The default color is Color::White.

[src]

Overrides the Debug level color with the given color.

The default color is Color::White.

[src]

Overrides the Trace level color with the given color.

The default color is Color::White.

[src]

Retrieves the default configuration. This has:

[src]

Colors the given log level with the color in this configuration corresponding to it's level.

The structure returned is opaque, but will print the LogLevel surrounded by ANSI color codes when displayed. This will work correctly for UNIX terminals, but due to a lack of support from the colored crate, this will not function in Windows.

[src]

Retrieves the color that a log level should be colored as.

Trait Implementations

impl Copy for ColoredLogLevelConfig
[src]

impl Clone for ColoredLogLevelConfig
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more