hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LoggerConfigLoader.hpp
Go to the documentation of this file.
1 
14 #ifndef LOGGER_CONFIG_LOADER_HPP
15 #define LOGGER_CONFIG_LOADER_HPP
16 
17 #include <iostream>
18 #include <Poco/AutoPtr.h>
19 #include <Poco/Configurable.h>
20 
21 namespace HCE
22 {
23 namespace handlers
24 {
25 //-----------------------------------------------------------------------------
27 {
28  // list names of constants using for initialization Poco::Logger
29  static const std::string sectionPatternFormatter;
30  static const std::string sectionFileChannel;
31  static const std::string sectionLogger;
32  static const std::string delimiter;
33 public:
34  LoggerConfigLoader(const std::string& nodeName, const Poco::Util::IniFileConfiguration::Keys& loggers, const std::string& configFileName="");
35  explicit LoggerConfigLoader(const std::string& nodeName, const std::string& configFileName="");
36  virtual ~LoggerConfigLoader(void);
37 
38  bool loadConfig(const std::string& configFileName);
39  static void defaultInitialization(void);
40 
41  std::string getErrorMsg(void) const {return errorMsg;}
42  bool isError(void) const {return _isError;}
43  static unsigned int getDebugLevel(void);
44 
45 protected:
46  void loadSection(Poco::Util::IniFileConfiguration& iniFileConfiguration,
47  const std::string& sectionName,
48  Poco::Configurable& configurable) throw (Poco::Exception);
49 
50  void loggerInitialization(Poco::Util::IniFileConfiguration& iniFileConfiguration,
51  const std::string& loggerName) throw (Poco::Exception);
52 
53  static std::string getLoggerSectionName(const std::string& sectionName,
54  const std::string& loggerName);
55 
56  static void getLoggers(Poco::Util::IniFileConfiguration& iniFileConfiguration,
57  Poco::Util::IniFileConfiguration::Keys& loggerNames);
58 
59  void checkExistSection(Poco::Util::IniFileConfiguration& iniFileConfiguration,
60  const Poco::Util::IniFileConfiguration::Keys& loggerNames) throw (Poco::Exception);
61 
62  static void checkExistSection(const Poco::Util::IniFileConfiguration::Keys& sections,
63  const std::string& sectionName) throw (Poco::Exception);
64 
65 protected:
66  std::string nodeName;
67  std::string errorMsg;
68  bool _isError;
69  Poco::Util::IniFileConfiguration::Keys loggers;
70 };
71 //-----------------------------------------------------------------------------
72 //-----------------------------------------------------------------------------
73 } // end namespace handlers
74 } // end namespace HCE
75 
76 #endif // LOGGER_CONFIG_LOADER_HPP