|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
use std::fmt; |
|
|
|
|
|
|
|
|
|
#[blonkus_ma::serialize_config] |
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] |
|
|
|
|
pub enum Level { |
|
|
|
@ -28,39 +30,19 @@ impl Default for Level {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl Level { |
|
|
|
|
pub const fn name(self) -> &'static str { |
|
|
|
|
impl fmt::Display for Level { |
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
|
|
|
|
match self { |
|
|
|
|
Self::Critical => "Critical", |
|
|
|
|
Self::Error => "Error", |
|
|
|
|
Self::Warning => "Warning", |
|
|
|
|
Self::Notice => "Notice", |
|
|
|
|
Self::Info => "Info", |
|
|
|
|
Self::Debug => "Debug", |
|
|
|
|
Self::Critical => f.write_str("Critical"), |
|
|
|
|
Self::Error => f.write_str("Error"), |
|
|
|
|
Self::Warning => f.write_str("Warning"), |
|
|
|
|
Self::Notice => f.write_str("Notice"), |
|
|
|
|
Self::Info => f.write_str("Info"), |
|
|
|
|
Self::Debug => f.write_str("Debug"), |
|
|
|
|
#[cfg(debug_assertions)] |
|
|
|
|
Self::Trace => "Trace", |
|
|
|
|
Self::Trace => f.write_str("Trace"), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[cfg(feature = "color-log")] |
|
|
|
|
pub fn color(self) -> termcolor::ColorSpec { |
|
|
|
|
use termcolor::Color; |
|
|
|
|
|
|
|
|
|
let mut color = termcolor::ColorSpec::new(); |
|
|
|
|
|
|
|
|
|
match self { |
|
|
|
|
Self::Critical => color.set_fg(Some(Color::Red)).set_intense(true), |
|
|
|
|
Self::Error => color.set_fg(Some(Color::Red)), |
|
|
|
|
Self::Warning => color.set_fg(Some(Color::Yellow)).set_intense(true), |
|
|
|
|
Self::Notice => color.set_fg(Some(Color::Yellow)), |
|
|
|
|
Self::Info => color.set_fg(Some(Color::Cyan)).set_intense(true), |
|
|
|
|
Self::Debug => color.set_fg(Some(Color::Cyan)), |
|
|
|
|
#[cfg(debug_assertions)] |
|
|
|
|
Self::Trace => color.set_fg(Some(Color::Magenta)).set_intense(true), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
color |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// EOF
|
|
|
|
|