mirror of
https://github.com/sadoyan/aralez.git
synced 2026-10-23 06:01:35 +08:00
Added log pattern to main.cfg
This commit is contained in:
@@ -259,7 +259,7 @@ async fn populate_file_upstreams(config: &mut Configuration, parsed: &Config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn parce_main_config(path: &str) -> AppConfig {
|
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");
|
let mut cfo: AppConfig = noyalib::from_str(&data).expect("Failed to parse main config file");
|
||||||
if let Ok(jwt_key) = env::var("JWT_KEY") {
|
if let Ok(jwt_key) = env::var("JWT_KEY") {
|
||||||
cfo.master_key = Some(jwt_key);
|
cfo.master_key = Some(jwt_key);
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ pub struct AppConfig {
|
|||||||
pub runuser: Option<String>,
|
pub runuser: Option<String>,
|
||||||
pub rungroup: Option<String>,
|
pub rungroup: Option<String>,
|
||||||
pub log_file: Option<String>,
|
pub log_file: Option<String>,
|
||||||
|
pub log_pattern: Option<String>,
|
||||||
pub tcp_keepalive_idle: Option<u64>,
|
pub tcp_keepalive_idle: Option<u64>,
|
||||||
pub tcp_keepalive_interval: Option<u64>,
|
pub tcp_keepalive_interval: Option<u64>,
|
||||||
pub tcp_keepalive_count: Option<usize>,
|
pub tcp_keepalive_count: Option<usize>,
|
||||||
|
|||||||
+5
-1
@@ -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 {
|
if let Some(location) = location {
|
||||||
let parts: Vec<&str> = location.splitn(4, ',').map(|s| s.trim()).collect();
|
let parts: Vec<&str> = location.splitn(4, ',').map(|s| s.trim()).collect();
|
||||||
|
|||||||
Reference in New Issue
Block a user