use glyphs::Color;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Level {
Debug,
Info,
Warn,
Error,
Fatal,
}
impl Level {
#[must_use]
pub const fn name(&self) -> &'static str {
match self {
Level::Debug => "DEBUG",
Level::Info => "INFO",
Level::Warn => "WARN",
Level::Error => "ERROR",
Level::Fatal => "FATAL",
}
}
#[must_use]
pub const fn short_name(&self) -> &'static str {
match self {
Level::Debug => "DBG",
Level::Info => "INF",
Level::Warn => "WRN",
Level::Error => "ERR",
Level::Fatal => "FTL",
}
}
#[must_use]
pub const fn icon(&self) -> &'static str {
match self {
Level::Debug => "đ",
Level::Info => "âšī¸",
Level::Warn => "â ī¸",
Level::Error => "â",
Level::Fatal => "đ",
}
}
#[must_use]
pub fn color(&self) -> Color {
match self {
Level::Debug => Color::from_hex("#71717A"), Level::Info => Color::from_hex("#3B82F6"), Level::Warn => Color::from_hex("#F59E0B"), Level::Error => Color::from_hex("#EF4444"), Level::Fatal => Color::from_hex("#DC2626"), }
}
}
impl std::fmt::Display for Level {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name())
}
}