use crate::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Level {
Verbose,
Debug,
Info,
Warning,
Critical,
Error,
Fatal,
}
impl Output for Level {
fn for_write(&self, f: &mut impl std::fmt::Write) {
match self {
Level::Verbose => write!(f, "[V]"),
Level::Debug => write!(f, "[D]"),
Level::Info => write!(f, "[I]"),
Level::Warning => write!(f, "[W]"),
Level::Critical => write!(f, "[C]"),
Level::Error => write!(f, "[E]"),
Level::Fatal => write!(f, "[F]"),
}.unwrap();
}
#[cfg(feature = "color")]
fn for_print(&self, f: &mut impl std::fmt::Write) {
match self {
Level::Verbose => write!(f, "\x1b[90m[V]\x1b[0m"), Level::Debug => write!(f, "\x1b[37m[D]\x1b[0m"), Level::Info => write!(f, "\x1b[32m[I]\x1b[0m"), Level::Warning => write!(f, "\x1b[33m[W]\x1b[0m"), Level::Critical => write!(f, "\x1b[38;5;208m[C]\x1b[0m"), Level::Error => write!(f, "\x1b[31m[E]\x1b[0m"), Level::Fatal => write!(f, "\x1b[31m[F]\x1b[0m"), }.unwrap();
}
#[cfg(not(feature = "color"))]
fn for_print(&self, f: &mut impl std::fmt::Write) {
self.for_write(f);
}
}