From 0cec8e78dec5192207ce9416943cf03ff53492de Mon Sep 17 00:00:00 2001
From: librelois <elois@ifee.fr>
Date: Thu, 18 Apr 2019 23:34:33 +0200
Subject: [PATCH] [fix] core:cli:  wrongly parsed log level since migration to
 structopt

---
 lib/core/core/cli/mod.rs |  2 +-
 lib/core/core/lib.rs     | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/core/core/cli/mod.rs b/lib/core/core/cli/mod.rs
index 4c9bdddb..4c89621c 100644
--- a/lib/core/core/cli/mod.rs
+++ b/lib/core/core/cli/mod.rs
@@ -41,7 +41,7 @@ pub struct DursOpt {
     profile_name: Option<String>,
     #[structopt(short = "l", long = "logs", raw(next_line_help = "true"))]
     /// Set log level. (Defaults to INFO).
-    /// Available levels: [OFF, ERROR, WARN, INFO, DEBUG, TRACE]
+    /// Available levels: [ERROR, WARN, INFO, DEBUG, TRACE]
     logs_level: Option<Level>,
     #[structopt(subcommand)]
     /// CoreSubCommand
diff --git a/lib/core/core/lib.rs b/lib/core/core/lib.rs
index 1de04dc4..aaa2a6d2 100644
--- a/lib/core/core/lib.rs
+++ b/lib/core/core/lib.rs
@@ -711,13 +711,13 @@ pub fn init_logger(profile: &str, soft_name: &'static str, cli_args: &ArgMatches
     log_file_path.push(format!("{}.log", soft_name));
 
     // Get log level
-    let log_level = match cli_args.value_of("logs_level").unwrap_or("i") {
-        "e" | "error" => Level::Error,
-        "w" | "warn" => Level::Warn,
-        "i" | "info" => Level::Info,
-        "d" | "debug" => Level::Debug,
-        "t" | "trace" => Level::Trace,
-        _ => panic!("Fatal error : unknow log level !"),
+    let log_level = match cli_args.value_of("logs_level").unwrap_or("INFO") {
+        "ERROR" => Level::Error,
+        "WARN" => Level::Warn,
+        "INFO" => Level::Info,
+        "DEBUG" => Level::Debug,
+        "TRACE" => Level::Trace,
+        _ => unreachable!("Structopt guarantees us that the string match necessarily with one of the variants of the enum Level"),
     };
 
     // Config logger
-- 
GitLab