1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use is_terminal::IsTerminal;

mod adaptive_value_provider;
pub use adaptive_value_provider::*;
mod logo;
pub use logo::*;
pub mod env;

#[derive(Debug, Clone, PartialEq, Eq, strum::EnumString)]
#[strum(serialize_all = "kebab-case")]
pub enum LoggingColor {
    Always,
    Auto,
    Never,
}

impl LoggingColor {
    pub fn coloring_enabled(&self) -> bool {
        match self {
            LoggingColor::Auto => std::io::stdout().is_terminal(),
            LoggingColor::Always => true,
            LoggingColor::Never => false,
        }
    }
}

impl Default for LoggingColor {
    fn default() -> Self {
        Self::Auto
    }
}