openvpn_mgmt_codec/
log_level.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum LogLevel {
6 Info,
8
9 Debug,
11
12 Warning,
14
15 NonFatal,
17
18 Fatal,
20
21 Custom(String),
23}
24
25impl LogLevel {
26 pub(crate) fn parse(s: &str) -> Self {
28 match s {
29 "I" => Self::Info,
30 "D" => Self::Debug,
31 "W" => Self::Warning,
32 "N" => Self::NonFatal,
33 "F" => Self::Fatal,
34 other => Self::Custom(other.to_owned()),
35 }
36 }
37}
38
39impl fmt::Display for LogLevel {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 match self {
42 Self::Info => f.write_str("I"),
43 Self::Debug => f.write_str("D"),
44 Self::Warning => f.write_str("W"),
45 Self::NonFatal => f.write_str("N"),
46 Self::Fatal => f.write_str("F"),
47 Self::Custom(s) => f.write_str(s),
48 }
49 }
50}