common_data_model/my_logger.rs
1use std::io::Write;
2
3use chrono::Local;
4use env_logger::Builder;
5use log::LevelFilter;
6
7/// Initializes the logger for the application.
8///
9/// The logger is configured to output messages in the following format:
10/// `YYYY-MM-DDTHH:MM:SS [LEVEL] - MESSAGE`
11///
12/// The default log level is `Info`.
13
14pub fn init_logger() {
15 Builder::new()
16 .format(|buf, record| {
17 writeln!(
18 buf,
19 "{} [{}] - {}",
20 Local::now().format("%Y-%m-%dT%H:%M:%S"),
21 record.level(),
22 record.args()
23 )
24 })
25 .filter(None, LevelFilter::Info)
26 .init();
27}