OrocosComponentLibrary  2.9.0
Category.hpp
1 #ifndef CATEGORY_HPP
2 #define CATEGORY_HPP 1
3 
4 #include <log4cpp/Category.hh>
5 #include "LoggingEvent.hpp"
6 #include "CategoryStream.hpp"
7 #include <rtt/Port.hpp>
8 
9 // forward declare
10 namespace RTT {
11  class ConnPolicy;
12 }
13 
14 namespace OCL {
15 namespace logging {
16 
17 // forward declare
18 class LoggingService;
19 
25 class Category : public log4cpp::Category
26 {
27 public:
28  virtual ~Category();
29 
30  // custom real-time versions - available to user
31  // these replace std::string versions in the base class
32 public:
33  virtual void log(log4cpp::Priority::Value priority,
34  const RTT::rt_string& message) throw();
35  void debug(const RTT::rt_string& message) throw();
36  void info(const RTT::rt_string& message) throw();
37  void notice(const RTT::rt_string& message) throw();
38  void warn(const RTT::rt_string& message) throw();
39  void error(const RTT::rt_string& message) throw();
40  void crit(const RTT::rt_string& message) throw();
41  void alert(const RTT::rt_string& message) throw();
42  void emerg(const RTT::rt_string& message) throw();
43  void fatal(const RTT::rt_string& message) throw();
44 
49  CategoryStream getRTStream(log4cpp::Priority::Value priority);
50 
51 protected:
52  void _logUnconditionally2(log4cpp::Priority::Value priority,
53  const RTT::rt_string& message) throw();
54 
55 
56  // real-time - available to user
57 public:
58  using log4cpp::Category::setPriority;
59  using log4cpp::Category::getPriority;
60  using log4cpp::Category::getChainedPriority;
61  using log4cpp::Category::isPriorityEnabled;
62 
63  using log4cpp::Category::setAdditivity;
64  using log4cpp::Category::getAdditivity;
65  using log4cpp::Category::getParent;
66 
67  using log4cpp::Category::isDebugEnabled;
68  using log4cpp::Category::isInfoEnabled;
69  using log4cpp::Category::isNoticeEnabled;
70  using log4cpp::Category::isWarnEnabled;
71  using log4cpp::Category::isErrorEnabled;
72  using log4cpp::Category::isCritEnabled;
73  using log4cpp::Category::isAlertEnabled;
74  using log4cpp::Category::isEmergEnabled;
75  using log4cpp::Category::isFatalEnabled;
76 
77 
78  // real-time (but uses locking) - available to user but BEWARE locking!
79 public:
80  using log4cpp::Category::getAppender;
81 
82 
83 
84  // NOT real-time and so _NOT_ available to user
85 protected:
86  using log4cpp::Category::getRoot;
87  using log4cpp::Category::setRootPriority;
88  using log4cpp::Category::getRootPriority;
89  using log4cpp::Category::getInstance;
90  using log4cpp::Category::exists;
91  using log4cpp::Category::getCurrentCategories;
92  using log4cpp::Category::shutdown;
93  using log4cpp::Category::getName;
94 
95  using log4cpp::Category::removeAllAppenders;
96  using log4cpp::Category::removeAppender;
97  using log4cpp::Category::addAppender;
98  using log4cpp::Category::setAppender;
99 
100  using log4cpp::Category::getAllAppenders;
101 
102  using log4cpp::Category::debugStream;
103  using log4cpp::Category::infoStream;
104  using log4cpp::Category::noticeStream;
105  using log4cpp::Category::warnStream;
106  using log4cpp::Category::errorStream;
107  using log4cpp::Category::critStream;
108  using log4cpp::Category::emergStream;
109  using log4cpp::Category::fatalStream;
110  using log4cpp::Category::getStream;
111  using log4cpp::Category::operator<<;
112 
113  using log4cpp::Category::callAppenders;
114 
115  using log4cpp::Category::log;
116  using log4cpp::Category::logva;
117  using log4cpp::Category::debug;
118  using log4cpp::Category::info;
119  using log4cpp::Category::notice;
120  using log4cpp::Category::warn;
121  using log4cpp::Category::error;
122  using log4cpp::Category::crit;
123  using log4cpp::Category::alert;
124  using log4cpp::Category::emerg;
125  using log4cpp::Category::fatal;
126 
127  using log4cpp::Category::_logUnconditionally;
128  using log4cpp::Category::_logUnconditionally2;
129 
130 
131 protected:
132  Category(const std::string& name,
133  log4cpp::Category* parent,
134  log4cpp::Priority::Value priority = log4cpp::Priority::NOTSET);
135 
136 protected:
141  virtual void callAppenders(const OCL::logging::LoggingEvent& event) throw();
142 
147  static std::string convertName(const std::string& name);
148 
149 public:
155  static log4cpp::Category* createOCLCategory(const std::string& name,
156  log4cpp::Category* parent,
157  log4cpp::Priority::Value priority);
158 
159 
160 protected:
161 //protected:
162  RTT::OutputPort<OCL::logging::LoggingEvent> log_port;
165 
166 public:
172  bool connectToLogPort(RTT::base::PortInterface& otherPort);
178  bool connectToLogPort(RTT::base::PortInterface& otherPort,
179  RTT::ConnPolicy& cp);
180 
181 private:
182  /* prevent copying and assignment */
183  Category(const Category& other);
184  Category& operator=(const Category& other);
185 };
186 
187 // namespaces
188 }
189 }
190 
191 #endif
A mirror of log4cpp::LoggingEvent, except using real-time capable strings.
This is a utility class which you can use to stream messages into a category object.
This component is responsible for reading the logging configuration setting up the logging categories...
The Orocos Component Library.
Definition: Component.hpp:43
A real-time capable category.
Definition: Category.hpp:25
Definition: Category.hpp:10