Skip to content

Commit

Permalink
Added custom logging configuration with date and time
Browse files Browse the repository at this point in the history
  • Loading branch information
okynos committed Jan 20, 2025
1 parent 9244a9f commit 5e0a4a0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use crate::utils;

pub fn init() -> (AppConfig, Ruleset) {
use std::path::Path;
use simplelog::WriteLogger;
use simplelog::Config;
use simplelog::{ WriteLogger, ConfigBuilder, format_description };
use std::fs;

println!("[INFO] Achiefs File Integrity Monitoring software starting!");
Expand All @@ -21,10 +20,16 @@ pub fn init() -> (AppConfig, Ruleset) {
).parent().unwrap().to_str().unwrap()
).unwrap();

// Modify the logger configuration
let log_config = ConfigBuilder::new()
.set_time_format_custom(format_description!(
"[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:4]"))
.build();

// Create logger output to write generated logs.
WriteLogger::init(
cfg.clone().get_level_filter(),
Config::default(),
log_config,
fs::OpenOptions::new()
.create(true)
.append(true)
Expand Down

0 comments on commit 5e0a4a0

Please sign in to comment.