1use std::path::PathBuf;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum LogFormat {
6 Json,
8 Human,
10}
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub enum RotationStrategy {
15 Daily,
17 Size(usize),
19}
20
21#[derive(Debug, Clone)]
23pub struct LogRotationConfig {
24 pub strategy: RotationStrategy,
26 pub max_files: usize,
28}
29
30#[derive(Debug, Clone)]
32pub struct LogConfig {
33 pub level: tracing::Level,
35
36 pub console_output: bool,
38 pub console_format: LogFormat,
40 pub console_colors: bool,
42 pub console_show_target: bool,
44 pub console_show_file: bool,
46 pub console_show_line: bool,
48
49 pub file_output: bool,
51 pub log_file: Option<PathBuf>,
53 pub file_format: LogFormat,
55 pub rotation: LogRotationConfig,
57}
58
59impl Default for LogRotationConfig {
60 fn default() -> Self {
61 Self {
62 strategy: RotationStrategy::Daily,
63 max_files: 7,
64 }
65 }
66}
67
68impl Default for LogConfig {
69 fn default() -> Self {
70 Self {
71 level: tracing::Level::INFO,
72 console_output: true,
73 console_format: LogFormat::Human,
74 console_colors: true,
75 console_show_target: true,
76 console_show_file: true,
77 console_show_line: true,
78 file_output: false,
79 log_file: None,
80 file_format: LogFormat::Json,
81 rotation: LogRotationConfig::default(),
82 }
83 }
84}