OrocosComponentLibrary  2.7.0
Category.hpp
00001 #ifndef CATEGORY_HPP
00002 #define CATEGORY_HPP 1
00003 
00004 #include <log4cpp/Category.hh>
00005 #include "LoggingEvent.hpp"
00006 #include "CategoryStream.hpp"
00007 #include <rtt/Port.hpp>
00008 
00009 namespace OCL {
00010 namespace logging {
00011 
00012 // forward declare
00013 class LoggingService;
00014 
00020 class Category : public log4cpp::Category
00021 {
00022 public:
00023     virtual ~Category();
00024 
00025     // custom real-time versions - available to user
00026     // these replace std::string versions in the base class
00027 public:
00028     virtual void log(log4cpp::Priority::Value priority, 
00029                      const RTT::rt_string& message) throw();
00030     void debug(const RTT::rt_string& message) throw();
00031     void info(const RTT::rt_string& message) throw();
00032     void notice(const RTT::rt_string& message) throw();
00033     void warn(const RTT::rt_string& message) throw();
00034     void error(const RTT::rt_string& message) throw();
00035     void crit(const RTT::rt_string& message) throw();
00036     void alert(const RTT::rt_string& message) throw();
00037     void emerg(const RTT::rt_string& message) throw();
00038     void fatal(const RTT::rt_string& message) throw();
00039 
00044     CategoryStream getRTStream(log4cpp::Priority::Value priority);
00045 
00046 protected:
00047     void _logUnconditionally2(log4cpp::Priority::Value priority, 
00048                               const RTT::rt_string& message) throw();
00049 
00050 
00051     // real-time - available to user
00052 public:
00053     using log4cpp::Category::setPriority;
00054     using log4cpp::Category::getPriority;
00055     using log4cpp::Category::getChainedPriority;
00056     using log4cpp::Category::isPriorityEnabled;
00057 
00058     using log4cpp::Category::setAdditivity;
00059     using log4cpp::Category::getAdditivity;
00060     using log4cpp::Category::getParent;
00061 
00062     using log4cpp::Category::isDebugEnabled;
00063     using log4cpp::Category::isInfoEnabled;
00064     using log4cpp::Category::isNoticeEnabled;
00065     using log4cpp::Category::isWarnEnabled;
00066     using log4cpp::Category::isErrorEnabled;
00067     using log4cpp::Category::isCritEnabled;
00068     using log4cpp::Category::isAlertEnabled;
00069     using log4cpp::Category::isEmergEnabled;
00070     using log4cpp::Category::isFatalEnabled;
00071 
00072 
00073     // real-time (but uses locking) - available to user but BEWARE locking!
00074 public:
00075     using log4cpp::Category::getAppender;
00076 
00077 
00078 
00079     // NOT real-time and so _NOT_ available to user
00080 protected:
00081     using log4cpp::Category::getRoot;
00082     using log4cpp::Category::setRootPriority;
00083     using log4cpp::Category::getRootPriority;
00084     using log4cpp::Category::getInstance;
00085     using log4cpp::Category::exists;
00086     using log4cpp::Category::getCurrentCategories;
00087     using log4cpp::Category::shutdown;
00088     using log4cpp::Category::getName; 
00089 
00090     using log4cpp::Category::removeAllAppenders;
00091     using log4cpp::Category::removeAppender;
00092     using log4cpp::Category::addAppender;
00093     using log4cpp::Category::setAppender;
00094 
00095     using log4cpp::Category::getAllAppenders;
00096 
00097     using log4cpp::Category::debugStream;
00098     using log4cpp::Category::infoStream;
00099     using log4cpp::Category::noticeStream;
00100     using log4cpp::Category::warnStream;
00101     using log4cpp::Category::errorStream;
00102     using log4cpp::Category::critStream;
00103     using log4cpp::Category::emergStream;
00104     using log4cpp::Category::fatalStream;
00105     using log4cpp::Category::getStream;
00106     using log4cpp::Category::operator<<;
00107 
00108     using log4cpp::Category::callAppenders;
00109 
00110     using log4cpp::Category::log;
00111     using log4cpp::Category::logva;
00112     using log4cpp::Category::debug;
00113     using log4cpp::Category::info;
00114     using log4cpp::Category::notice;
00115     using log4cpp::Category::warn;
00116     using log4cpp::Category::error;
00117     using log4cpp::Category::crit;
00118     using log4cpp::Category::alert;
00119     using log4cpp::Category::emerg;
00120     using log4cpp::Category::fatal;
00121 
00122     using log4cpp::Category::_logUnconditionally;
00123     using log4cpp::Category::_logUnconditionally2;
00124         
00125 
00126 protected:
00127     Category(const std::string& name,   
00128              log4cpp::Category* parent, 
00129              log4cpp::Priority::Value priority = log4cpp::Priority::NOTSET);
00130 
00131 protected:
00136     virtual void callAppenders(const OCL::logging::LoggingEvent& event) throw();
00137 
00142     static std::string convertName(const std::string& name);    
00143 
00144 public:
00150     static log4cpp::Category* createOCLCategory(const std::string& name, 
00151                                                 log4cpp::Category* parent, 
00152                                                 log4cpp::Priority::Value priority);
00153 
00154 
00155 protected:
00156 //protected:
00157     RTT::OutputPort<OCL::logging::LoggingEvent>   log_port;
00159     friend class OCL::logging::LoggingService;
00160     
00161 public:
00167     bool connectToLogPort(RTT::base::PortInterface& otherPort);
00168 
00169 private:
00170     /* prevent copying and assignment */
00171     Category(const Category& other);
00172     Category& operator=(const Category& other);
00173 };
00174 
00175 // namespaces
00176 }
00177 }
00178 
00179 #endif