diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-04-27 01:17:25 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-05-30 09:32:07 +0200 |
commit | fb8b50fa9a75b50becf9576c22f0041f9b551fea (patch) | |
tree | 8c3c22f07ebbb15300bfd429b7591cc86d1c5ee5 /lib/core | |
parent | 185ec25b9e388bb76b21c212b4a4123f5533f71d (diff) |
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>
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/libimagrt/Cargo.toml | 2 | ||||
-rw-r--r-- | lib/core/libimagrt/src/logger.rs | 32 |
2 files changed, 2 insertions, 32 deletions
diff --git a/lib/core/libimagrt/Cargo.toml b/lib/core/libimagrt/Cargo.toml index 31a04a8e..f9b83932 100644 --- a/lib/core/libimagrt/Cargo.toml +++ b/lib/core/libimagrt/Cargo.toml @@ -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" diff --git a/lib/core/libimagrt/src/logger.rs b/lib/core/libimagrt/src/logger.rs index 8aabcb5e..956d251d 100644 --- a/lib/core/libimagrt/src/logger.rs +++ b/lib/core/libimagrt/src/logger.rs @@ -355,41 +355,11 @@ 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>); impl<'a> Partial<'a> for LoggingModuleConfigMap { |