diff --git a/src/utils/parceyaml.rs b/src/utils/parceyaml.rs index 8cb47f1..aa83ddb 100644 --- a/src/utils/parceyaml.rs +++ b/src/utils/parceyaml.rs @@ -259,7 +259,7 @@ async fn populate_file_upstreams(config: &mut Configuration, parsed: &Config) { } } pub fn parce_main_config(path: &str) -> AppConfig { - let data = fs::read_to_string(path).unwrap(); + let data = fs::read_to_string(path).expect("Failed to read main config file"); let mut cfo: AppConfig = noyalib::from_str(&data).expect("Failed to parse main config file"); if let Ok(jwt_key) = env::var("JWT_KEY") { cfo.master_key = Some(jwt_key); diff --git a/src/utils/structs.rs b/src/utils/structs.rs index 1ec6b1b..ce45eb3 100644 --- a/src/utils/structs.rs +++ b/src/utils/structs.rs @@ -131,6 +131,7 @@ pub struct AppConfig { pub runuser: Option, pub rungroup: Option, pub log_file: Option, + pub log_pattern: Option, pub tcp_keepalive_idle: Option, pub tcp_keepalive_interval: Option, pub tcp_keepalive_count: Option, diff --git a/src/web/logging.rs b/src/web/logging.rs index 6471376..725a516 100644 --- a/src/web/logging.rs +++ b/src/web/logging.rs @@ -44,7 +44,11 @@ pub fn log_builder(conf: &AppConfig, location: &Option) { } }; - let pattern = "{d(%Y-%m-%d %H:%M:%S)} {l} {t} - {m}\n"; + let mut pat: String = "{d(%Y-%m-%d %H:%M:%S)} {l} - {m} {n}".to_string(); + if let Some(ptrn) = conf.log_pattern.clone() { + pat = ptrn; + } + let pattern = pat.as_str(); if let Some(location) = location { let parts: Vec<&str> = location.splitn(4, ',').map(|s| s.trim()).collect();