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
error: Color
The color to color logs with the Error
level.
warn: Color
The color to color logs with the Warn
level.
info: Color
The color to color logs with the Info
level.
debug: Color
The color to color logs with the Debug
level.
trace: Color
The color to color logs with the Trace
level.
Methods
impl ColoredLogLevelConfig
[src]
fn new() -> Self
[src]
Creates a new ColoredLogLevelConfig with the default colors.
This matches the behavior of ColoredLogLevelConfig::default
.
fn error(self, error: Color) -> Self
[src]
Overrides the Error
level color with the given color.
The default color is Color::Red
.
fn warn(self, warn: Color) -> Self
[src]
Overrides the Warn
level color with the given color.
The default color is Color::Yellow
.
fn info(self, info: Color) -> Self
[src]
Overrides the Info
level color with the given color.
The default color is Color::White
.
fn debug(self, debug: Color) -> Self
[src]
Overrides the Debug
level color with the given color.
The default color is Color::White
.
fn trace(self, trace: Color) -> Self
[src]
Overrides the Trace
level color with the given color.
The default color is Color::White
.
fn default() -> Self
[src]
Retrieves the default configuration. This has:
Error
asColor::Red
Warn
asColor::Yellow
Info
asColor::White
Debug
asColor::White
Trace
asColor::White
fn color(&self, level: LogLevel) -> WithFgColor<LogLevel>
[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.
fn get_color(&self, level: &LogLevel) -> Color
[src]
Retrieves the color that a log level should be colored as.
Trait Implementations
impl Copy for ColoredLogLevelConfig
[src]
impl Clone for ColoredLogLevelConfig
[src]
fn clone(&self) -> ColoredLogLevelConfig
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more