/[usata]/usata2/src/main.cpp
ViewVC logotype

Diff of /usata2/src/main.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by skunix, Sun Dec 26 08:03:34 2004 UTC revision 1.17 by skunix, Sun Dec 26 08:34:20 2004 UTC
# Line 12  Line 12 
12  //  //
13  // $Id$  // $Id$
14  // $Log$  // $Log$
15    // Revision 1.17  2004/12/26 08:34:20  skunix
16    // added getting logging prefixes from config
17    //
18  // Revision 1.16  2004/12/26 08:03:34  skunix  // Revision 1.16  2004/12/26 08:03:34  skunix
19  // changed lambda::bind's to boost::binds  // changed lambda::bind's to boost::binds
20  //  //
# Line 87  namespace usata Line 90  namespace usata
90          Configuration* parse_options(int argc, char **argv);          Configuration* parse_options(int argc, char **argv);
91  }  }
92    
93    struct { std::string confkey; int level;} PFXData[] =
94            { { "debug", log::Level::DEBUG },
95              { "info", log::Level::INFO},
96              { "warning", log::Level::WARNING},
97              { "error", log::Level::ERROR},
98              { "",99}
99            };
100    
101    void setup_log()
102    {
103            ConfigSection conf("log/prefix");
104            std::string empty_str("");
105            for (int index=0; PFXData[index].level != 99; ++index)
106            {
107                    std::string prefix=conf.get(PFXData[index].confkey, empty_str);
108                    if (!prefix.empty())
109                            log::server.set_prefix(PFXData[index].level, prefix);
110            }
111            return;
112    }
113    
114  int main(int argc, char **argv)  int main(int argc, char **argv)
115  {  {
116          init_config();          init_config();
117          cxx_init();          cxx_init();
118    
         log::server.set_prefix(log::Level::DEBUG, "(DBG)");  
         log::server.set_prefix(log::Level::WARNING, "(WRN)");  
         log::server.set_prefix(log::Level::ERROR, "(ERR)");  
119          Configuration* op_conf = parse_options(argc, argv);          Configuration* op_conf = parse_options(argc, argv);
120    
121          // load config          // load config
122          ConfigSection csection("config");          ConfigSection csection("config");
123          std::string cfile = csection.get("filename",get_default_config_file());          std::string cfile = csection.get("filename",get_default_config_file());
   
124          log::stream << boost::format("Loading config file \"%1%\"\n") % cfile;          log::stream << boost::format("Loading config file \"%1%\"\n") % cfile;
125          log::Stream2 s(log::Level::INFO);          log::Stream2 s(log::Level::INFO);
126            
127          s << "some message" << " eh?" <<log::EndLog() ;          s << "some message" << " eh?" <<log::EndLog() ;
128          load_config(cfile);          load_config(cfile);
129            setup_log();
130          op_conf->value_export(get_configuration());          op_conf->value_export(get_configuration());
131          ConfigWatcher cfgw(get_configuration()->watch("config/test_var", &watcher, 0));          ConfigWatcher cfgw(get_configuration()->watch("config/test_var", &watcher, 0));
132          csection.set("test_var", "horus");          csection.set("test_var", "horus");

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26