Skip to content
Snippets Groups Projects
Commit 0cec8e78 authored by Éloïs's avatar Éloïs
Browse files

[fix] core:cli: wrongly parsed log level since migration to structopt

parent c5c01361
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ pub struct DursOpt { ...@@ -41,7 +41,7 @@ pub struct DursOpt {
profile_name: Option<String>, profile_name: Option<String>,
#[structopt(short = "l", long = "logs", raw(next_line_help = "true"))] #[structopt(short = "l", long = "logs", raw(next_line_help = "true"))]
/// Set log level. (Defaults to INFO). /// 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>, logs_level: Option<Level>,
#[structopt(subcommand)] #[structopt(subcommand)]
/// CoreSubCommand /// CoreSubCommand
......
...@@ -711,13 +711,13 @@ pub fn init_logger(profile: &str, soft_name: &'static str, cli_args: &ArgMatches ...@@ -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)); log_file_path.push(format!("{}.log", soft_name));
// Get log level // Get log level
let log_level = match cli_args.value_of("logs_level").unwrap_or("i") { let log_level = match cli_args.value_of("logs_level").unwrap_or("INFO") {
"e" | "error" => Level::Error, "ERROR" => Level::Error,
"w" | "warn" => Level::Warn, "WARN" => Level::Warn,
"i" | "info" => Level::Info, "INFO" => Level::Info,
"d" | "debug" => Level::Debug, "DEBUG" => Level::Debug,
"t" | "trace" => Level::Trace, "TRACE" => Level::Trace,
_ => panic!("Fatal error : unknow log level !"), _ => unreachable!("Structopt guarantees us that the string match necessarily with one of the variants of the enum Level"),
}; };
// Config logger // Config logger
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment