Remove boilerplate by enabling serde in "log" dependency
This patch adds the "serde" feature to the "log" dependency, so we can deserialize logging levels directly into "log" types. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
185ec25b9e
commit
fb8b50fa9a
2 changed files with 2 additions and 32 deletions
|
@ -45,7 +45,7 @@ features = ["suggestions", "color", "wrap_help"]
|
|||
[dependencies.log]
|
||||
version = "0.4"
|
||||
default-features = false
|
||||
features = ["std"]
|
||||
features = ["std", "serde"]
|
||||
|
||||
[dependencies.handlebars]
|
||||
version = "^1.0.5"
|
||||
|
|
|
@ -355,40 +355,10 @@ fn aggregate_module_settings(_matches: &ArgMatches, config: Option<&Value>)
|
|||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct LoggingModuleConfig {
|
||||
pub destinations: Option<Vec<String>>,
|
||||
pub level: Option<LogLevel>,
|
||||
pub level: Option<Level>,
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
enum LogLevel {
|
||||
#[serde(rename = "trace")]
|
||||
Trace,
|
||||
|
||||
#[serde(rename = "debug")]
|
||||
Debug,
|
||||
|
||||
#[serde(rename = "info")]
|
||||
Info,
|
||||
|
||||
#[serde(rename = "warn")]
|
||||
Warn,
|
||||
|
||||
#[serde(rename = "error")]
|
||||
Error,
|
||||
}
|
||||
|
||||
impl Into<Level> for LogLevel {
|
||||
fn into(self) -> Level {
|
||||
match self {
|
||||
LogLevel::Trace => Level::Trace,
|
||||
LogLevel::Debug => Level::Debug,
|
||||
LogLevel::Info => Level::Info,
|
||||
LogLevel::Warn => Level::Warn,
|
||||
LogLevel::Error => Level::Error,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct LoggingModuleConfigMap(BTreeMap<String, LoggingModuleConfig>);
|
||||
|
||||
|
|
Loading…
Reference in a new issue