2023-06-11 19:17:50 +05:00
|
|
|
use simple_log::LogConfigBuilder;
|
|
|
|
|
|
|
|
|
|
use crate::config;
|
|
|
|
|
use crate::APP_LOG_DIR;
|
|
|
|
|
|
|
|
|
|
pub fn init_logging() -> Result<(), String> {
|
|
|
|
|
// configure logging
|
|
|
|
|
let config = LogConfigBuilder::builder()
|
2025-12-11 23:43:50 +05:00
|
|
|
.path(format!(
|
|
|
|
|
"{}/{}",
|
|
|
|
|
APP_LOG_DIR.get().unwrap().display(),
|
|
|
|
|
config::LOG_FILE_NAME
|
|
|
|
|
))
|
2023-06-11 19:17:50 +05:00
|
|
|
.size(1 * 100)
|
|
|
|
|
.roll_count(10)
|
|
|
|
|
.time_format("%Y-%m-%d %H:%M:%S.%f") //E.g:%H:%M:%S.%f
|
|
|
|
|
.level("debug")
|
|
|
|
|
.output_file()
|
|
|
|
|
.output_console()
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
simple_log::new(config)?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
2025-12-11 23:43:50 +05:00
|
|
|
}
|