modbus_relay/config/
logging.rs1use serde::{Deserialize, Serialize};
2use tracing::level_filters::LevelFilter;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5#[serde(deny_unknown_fields)]
6pub struct Config {
7 pub log_dir: String,
9
10 pub trace_frames: bool,
12
13 pub level: String,
15
16 pub format: String,
18
19 pub include_location: bool,
21
22 pub thread_ids: bool,
24
25 pub thread_names: bool,
27}
28
29impl Default for Config {
30 fn default() -> Self {
31 Self {
32 log_dir: "logs".to_string(),
33 trace_frames: false,
34 level: "info".to_string(),
35 format: "pretty".to_string(),
36 include_location: false,
37 thread_ids: false,
38 thread_names: false,
39 }
40 }
41}
42
43impl Config {
44 pub fn get_level_filter(&self) -> LevelFilter {
45 match self.level.to_lowercase().as_str() {
46 "error" => LevelFilter::ERROR,
47 "warn" => LevelFilter::WARN,
48 "info" => LevelFilter::INFO,
49 "debug" => LevelFilter::DEBUG,
50 "trace" => LevelFilter::TRACE,
51 _ => LevelFilter::INFO, }
53 }
54}