hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Log.hpp
Go to the documentation of this file.
1 /*
2  * Log.hpp
3  *
4  * Created on: Dec 13, 2012
5  * Author: handler
6  */
7 
8 #ifndef LOG_HPP
9 #define LOG_HPP
10 
11 
13 #ifdef _WIN32
14 #include <Poco/EventLogChannel.h>
15 #endif
16 
17 
19 #ifdef __linux__
20 #include <Poco/SyslogChannel.h>
21 #endif
22 
23 
25 #include <Poco/Logger.h>
26 #include <Poco/Message.h>
27 #include <Poco/Net/RemoteSyslogChannel.h>
28 #include <Poco/ConsoleChannel.h>
29 #include <Poco/NullChannel.h>
30 #include <Poco/PatternFormatter.h>
31 #include <Poco/FormattingChannel.h>
32 #include <Poco/FileChannel.h>
33 #include <Poco/AsyncChannel.h>
34 #include <Poco/SplitterChannel.h>
35 #include <Poco/AutoPtr.h>
36 #include "Poco/SharedPtr.h"
37 #include <Poco/NumberFormatter.h>
38 #include <Poco/LogStream.h>
39 
43 #include <string>
44 
45 
46 namespace HCE
47 {
48 
49 
50 #define SET_MSG_FIELDS(_msg) { _msg.setSource(std::string(__FILE__) + ":" + std::string(__LINE__); \
51  _msg.setText(std::string(__FUNCTION__)); }
52 
53 
54 namespace logger
55 {
56 
57 
58 enum
59 {
62 };
63 
64 
65 class Log
66 {
67 public:
68  static void log(Poco::Message&);
69  static void log(const std::string& msg)
70  {
71  Poco::Logger::root().information(msg);
72  }
73  static void setChannel(const std::string& name, const unsigned int type) {}
74  static Poco::Logger& getChannel(const std::string& name, const unsigned int type) { return Poco::Logger::get("ch1"); }
75 public:
76  static Poco::LogStream stream;
77  Log();
78  virtual ~Log();
79 private:
80  std::vector<std::string> _v;
81 private:
82 
83  Poco::AutoPtr<Poco::NullChannel> _null;
84 
86  Poco::AutoPtr<Poco::FormattingChannel> _console;
87 
89  Poco::AutoPtr<Poco::FormattingChannel> _file;
90 
92  Poco::AutoPtr<Poco::SplitterChannel> _pool;
93 
95  #ifdef __linux__
96  Poco::AutoPtr<Poco::SyslogChannel> _sysLog;
97  #endif
98 
100  #ifdef _WIN32
101  Poco::AutoPtr<Poco::EventLogChannel> _eventLog;
102  #endif
103 
105  Poco::AutoPtr<Poco::Net::RemoteSyslogChannel> _remoteSysLog;
106 
108  Poco::AutoPtr<Poco::AsyncChannel> _async;
109 };
110 
111 
112 } /* namespace logger */
113 
114 
115 } /* namespace HCE */
116 
117 
118 #endif /* LOG_H_ */