From b08bf49f31df65ec106cd8378d866a990054801a Mon Sep 17 00:00:00 2001 From: donghui <549136742@qq.com> Date: Thu, 8 Oct 2020 15:50:32 +0800 Subject: [PATCH] fix: modify default logger to stdout without -D/-log_path argument --- src/main.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index fc8078d30..4d77d9a62 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,21 +49,19 @@ fn run() -> Result<()> { let cmd_args = create_args_parser().get_matches()?; if let Some(logfile_path) = cmd_args.value_of("display log") { - if logfile_path.is_empty() { - logger::init_logger_with_env(Some(Box::new(std::io::stdout()))) - .chain_err(|| "Failed to init logger.")?; - } else { - let logfile = std::fs::OpenOptions::new() - .read(false) - .write(true) - .append(true) - .create(true) - .mode(0o640) - .open(logfile_path) - .chain_err(|| "Failed to open log file")?; - logger::init_logger_with_env(Some(Box::new(logfile))) - .chain_err(|| "Failed to init logger.")?; - } + let logfile = std::fs::OpenOptions::new() + .read(false) + .write(true) + .append(true) + .create(true) + .mode(0o640) + .open(logfile_path) + .chain_err(|| "Failed to open log file")?; + logger::init_logger_with_env(Some(Box::new(logfile))) + .chain_err(|| "Failed to init logger.")?; + } else { + logger::init_logger_with_env(Some(Box::new(std::io::stdout()))) + .chain_err(|| "Failed to init logger.")?; } std::panic::set_hook(Box::new(|panic_msg| { -- Gitee