From f3a68a269b1e7972442ccbe5d6ee3e5a3f11a8bc Mon Sep 17 00:00:00 2001 From: Songtronix Date: Fri, 20 Dec 2019 15:59:50 +0100 Subject: [PATCH] change(log): only print out log file errors, no panic --- voxygen/src/logging.rs | 21 ++++++++++----------- voxygen/src/settings.rs | 8 +------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/voxygen/src/logging.rs b/voxygen/src/logging.rs index 78b9587eea..48fb256e95 100644 --- a/voxygen/src/logging.rs +++ b/voxygen/src/logging.rs @@ -40,17 +40,12 @@ pub fn init( )) }); - // Based on settings ignore errors incase log file can't be created - if !settings.log.ignore_errors { - file_cfg = file_cfg.chain( - fern::log_file(&format!("voxygen-{}.log", time.format("%Y-%m-%d-%H"))) - .expect("Failed to create log file!"), - ); - } else { - if let Ok(log_file) = fern::log_file(&format!("voxygen-{}.log", time.format("%Y-%m-%d-%H"))) - { - file_cfg = file_cfg.chain(log_file); - } + // Try to create the log file. + // Incase of it failing we simply print it out to the console. + let mut log_file_created = Ok(()); + match fern::log_file(&format!("voxygen-{}.log", time.format("%Y-%m-%d-%H"))) { + Ok(log_file) => file_cfg = file_cfg.chain(log_file), + Err(e) => log_file_created = Err(e), } let stdout_cfg = fern::Dispatch::new() @@ -70,4 +65,8 @@ pub fn init( base.chain(stdout_cfg) .apply() .expect("Failed to setup logging!"); + + if let Err(e) = log_file_created { + log::error!("Failed to create log file! {}", e); + } } diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 24672153dd..e2a567f174 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -158,17 +158,11 @@ pub struct Log { // Whether to create a log file or not. // Default is to create one. pub log_to_file: bool, - // Should we ignore errors if we are unable to create the log file - // Default is to panic if log file can't be created. - pub ignore_errors: bool, } impl Default for Log { fn default() -> Self { - Self { - log_to_file: true, - ignore_errors: false, - } + Self { log_to_file: true } } }