Added log pattern to main.cfg

This commit is contained in:
Ara Sadoyan
2026-09-16 19:18:18 +02:00
parent 444579eefe
commit 02a329e66b
3 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -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);
+1
View File
@@ -131,6 +131,7 @@ pub struct AppConfig {
pub runuser: Option<String>,
pub rungroup: Option<String>,
pub log_file: Option<String>,
pub log_pattern: Option<String>,
pub tcp_keepalive_idle: Option<u64>,
pub tcp_keepalive_interval: Option<u64>,
pub tcp_keepalive_count: Option<usize>,
+5 -1
View File
@@ -44,7 +44,11 @@ pub fn log_builder(conf: &AppConfig, location: &Option<String>) {
}
};
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();