layla_log/
setting.rs

1use super::LogLevel;
2
3/// the configuration of the logger.
4#[derive(Debug)]
5pub struct Setting {
6    /// where stores the log files.
7    pub dir_path: String,
8    /// the maximum number of logs in a single file.
9    pub single_length: usize,
10    /// define the minimum [`LogLevel`] of the log that should be written. (inclusive)
11    pub file_record_level: LogLevel,
12    /// define the minimum [`LogLevel`] of the log that should be printed. (inclusive)
13    pub terminal_print_level: LogLevel,
14    /// define to show the detailed time or not.
15    pub time_detailed_display: bool,
16    /// the prefix of the time.
17    pub file_time_format: String,
18    /// the time zone of the log.
19    pub time_zone: i32,
20    /// setting whether to print the log to the terminal.
21    pub print_out: bool,
22    /// setting whether to log or not
23    pub disabled: bool,
24}
25
26impl std::default::Default for Setting {
27    /// Provide default settings, and the logger can use the default setting to initialize itself.
28    fn default() -> Self {
29        let terminal_print_level = if cfg!(debug_assertions) {
30            LogLevel::Debug
31        } else {
32            LogLevel::Info
33        };
34
35        Setting {
36            dir_path: "./logs".to_string(),
37            single_length: 0,
38            file_record_level: LogLevel::Trace,
39            terminal_print_level,
40            time_detailed_display: false,
41            file_time_format: "%Y-%m-%d".to_string(),
42            time_zone: 0,
43            print_out: false,
44            disabled: false,
45        }
46    }
47}
48
49unsafe impl Send for Setting {}