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:
Matthias Beyer 2019-04-27 01:17:25 +02:00
parent 185ec25b9e
commit fb8b50fa9a
2 changed files with 2 additions and 32 deletions

View file

@ -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"

View file

@ -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>);