1use crate::*;
2
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
7pub enum Level {
8 Verbose,
9 Debug,
10 Info,
11 Warning,
12 Critical,
13 Error,
14 Fatal,
17}
18
19
20impl Output for Level {
21 fn for_write(&self, f: &mut impl std::fmt::Write) {
22 match self {
23 Level::Verbose => write!(f, "[V]"),
24 Level::Debug => write!(f, "[D]"),
25 Level::Info => write!(f, "[I]"),
26 Level::Warning => write!(f, "[W]"),
27 Level::Critical => write!(f, "[C]"),
28 Level::Error => write!(f, "[E]"),
29 Level::Fatal => write!(f, "[F]"),
30 }.unwrap();
31 }
32
33 #[cfg(feature = "color")]
34 fn for_print(&self, f: &mut impl std::fmt::Write) {
35 match self {
36 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();
44 }
45
46 #[cfg(not(feature = "color"))]
47 fn for_print(&self, f: &mut impl std::fmt::Write) {
48 self.for_write(f);
49 }
50}