1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
crate::ix!();

impl ArgsManagerInner {

    /**
      | Helper function for LogArgs().
      |
      */
    pub fn log_args_prefix(&self, 
        prefix:  &str,
        section: &str,
        args:    &HashMap<String,Vec<SettingsValue>>)  {
        
        let section_str: String = match section.is_empty() {
            true   => "".to_string(),
            false  => format!{"[{}] ", section}
        };

        for arg in args.iter() {
            for value in arg.1.iter() {

                let flags: Option::<u32> = {
                    let x = format!{"-{}", arg.0};
                    self.get_arg_flags(&x)
                };

                if flags.is_some() {

                    let value_str: String = match (flags.unwrap() & ArgsManagerFlags::SENSITIVE.bits()) != 0 {
                        true   => "****".to_string(),
                        false  => value.0.write(None,None)
                    };

                    log_printf!(
                        "%s %s%s=%s\n", 
                        prefix, 
                        section_str, 
                        arg.0, 
                        &value_str
                    );
                }
            }
        }
    }
    
    /**
      | Log the config file options and the command
      | line arguments, useful for troubleshooting.
      |
      */
    pub fn log_args(&self)  {
        
        for section in self.settings.ro_config.iter() {
            self.log_args_prefix("Config file arg:", section.0, section.1);
        }

        for setting in self.settings.rw_settings.iter() {
            log_printf!(
                "Setting file arg: %s = %s\n", 
                setting.0, 
                setting.1.write()
            );
        }

        self.log_args_prefix(
            "Command-line arg:", 
            "", 
            &self.settings.command_line_options
        );
    }
}