alto_logger/options/
color.rs

1use crate::Color;
2
3/// Color configuration for the logger
4#[derive(Copy, Clone, Debug)]
5pub struct ColorConfig {
6    /// Color for the `TRACE` level. Default: `Blue`
7    pub level_trace: Color,
8    /// Color for the `DEBUG` level. Default: `Cyan`
9    pub level_debug: Color,
10    /// Color for the `INFO` level. Default: `Green`
11    pub level_info: Color,
12    /// Color for the `WARN` level. Default: `Yellow`
13    pub level_warn: Color,
14    /// Color for the `ERROR` level. Default: `Red`
15    pub level_error: Color,
16
17    /// Color for the timestamp field. Default: `#767676`
18    pub timestamp: Color,
19    /// Color for the target field. Default: `#AF5F5F`
20    pub target: Color,
21    /// Color for the continuation field. Default: `#3A3A3A`
22    pub continuation: Color,
23    /// Color for the message field. Default: `#FFFFFF`
24    pub message: Color,
25}
26
27impl ColorConfig {
28    /// Create a monochrome (e.g. all 'white') color configuration
29    pub const fn monochrome() -> Self {
30        Self {
31            level_trace: Color::White,
32            level_debug: Color::White,
33            level_info: Color::White,
34            level_warn: Color::White,
35            level_error: Color::White,
36            timestamp: Color::White,
37            target: Color::White,
38            continuation: Color::White,
39            message: Color::White,
40        }
41    }
42
43    /// Only the levels should have the default colors, the rest should be monochrome
44    pub const fn only_levels() -> Self {
45        Self {
46            level_trace: Color::Blue,
47            level_debug: Color::Cyan,
48            level_info: Color::Green,
49            level_warn: Color::Yellow,
50            level_error: Color::Red,
51            ..Self::monochrome()
52        }
53    }
54}
55
56impl Default for ColorConfig {
57    fn default() -> Self {
58        Self {
59            level_trace: Color::Blue,
60            level_debug: Color::Cyan,
61            level_info: Color::Green,
62            level_warn: Color::Yellow,
63            level_error: Color::Red,
64
65            timestamp: Color::Ansi256(243),
66            target: Color::Ansi256(131),
67            continuation: Color::Ansi256(237),
68            message: Color::Ansi256(231),
69        }
70    }
71}