backbone_core/config/
logging_config.rs1use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct LoggingConfig {
10 #[serde(default = "default_log_level")]
12 pub level: String,
13 #[serde(default = "default_true")]
15 pub structured: bool,
16 #[serde(default = "default_log_format")]
18 pub format: String,
19 #[serde(default = "default_log_targets")]
21 pub targets: Vec<String>,
22 #[serde(default)]
24 pub file: Option<LoggingFileConfig>,
25}
26
27fn default_true() -> bool { true }
28fn default_log_level() -> String { "info".to_string() }
29fn default_log_format() -> String { "json".to_string() }
30fn default_log_targets() -> Vec<String> { vec!["console".to_string()] }
31
32impl Default for LoggingConfig {
33 fn default() -> Self {
34 Self {
35 level: default_log_level(),
36 structured: true,
37 format: default_log_format(),
38 targets: default_log_targets(),
39 file: None,
40 }
41 }
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct LoggingFileConfig {
47 pub path: String,
49 #[serde(default)]
51 pub max_size: Option<String>,
52 #[serde(default)]
54 pub max_files: Option<u32>,
55 #[serde(default)]
57 pub compress: Option<bool>,
58}