diff --git a/src/config/mod.rs b/src/config/mod.rs index b919dce..c28cd4e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -9,6 +9,8 @@ use log::{info, LevelFilter, trace}; use serde::Deserialize; use serde_json::Value; use tokio::runtime::{Builder, Runtime}; +use std::io::Write; +use crate::config::time::current_formatted_time; pub mod time; @@ -75,7 +77,13 @@ pub fn init_runtime () -> std::io::Result { pub fn init_configs (config_path : Option<&String>) -> std::io::Result<()> { //init logger - env_logger::builder().filter_level(LevelFilter::Info).init(); + env_logger::builder() + .format(|buf,rec| { + let style = buf.default_level_style(rec.level()); + writeln!(buf, "[{} {style}{}{style:#} librespeed_rs] {}",current_formatted_time(),rec.level(), rec.args()) + }) + .filter_level(LevelFilter::Info).init(); + println!("{HEAD_ART}"); //find server configs match config_path { Some(config_path) => { @@ -190,4 +198,12 @@ pub static ROUTES: OnceLock> = OnceLock::new(); pub static GARBAGE_DATA: OnceLock> = OnceLock::new(); pub static SERVER_CONFIG: OnceLock = OnceLock::new(); pub static FONT: OnceLock = OnceLock::new(); -pub static DEF_ASSETS : Dir = include_dir!("assets"); \ No newline at end of file +pub static DEF_ASSETS : Dir = include_dir!("assets"); +pub const HEAD_ART : &str = r#" + _ _ _ _ + | (_) |__ _ __ ___ ___ _ __ ___ ___ __| | _ __ ___ + | | | '_ \| '__/ _ \/ __| '_ \ / _ \/ _ \/ _` |_____| '__/ __| + | | | |_) | | | __/\__ \ |_) | __/ __/ (_| |_____| | \__ \ + |_|_|_.__/|_| \___||___/ .__/ \___|\___|\__,_| |_| |___/ + |_| +"#; \ No newline at end of file diff --git a/src/config/time.rs b/src/config/time.rs index ef69968..20b358d 100644 --- a/src/config/time.rs +++ b/src/config/time.rs @@ -7,6 +7,10 @@ pub fn convert_time_local (time : i64) -> String { local.format("%Y-%m-%d %H:%M:%S").to_string() } +pub fn current_formatted_time() -> String { + Local::now().format("%Y-%m-%d %H:%M:%S%.3f").to_string() +} + #[allow(dead_code)] pub fn convert_time_utc (time : i64) -> String { let dt = DateTime::from_timestamp_millis(time).unwrap();