1 #include "logging/Category.hpp" 2 #include <rtt/Logger.hpp> 3 #include <rtt/ConnPolicy.hpp> 4 #include <log4cpp/NDC.hh> 5 #include <log4cpp/HierarchyMaintainer.hh> 12 Category::Category(
const std::string& name,
13 log4cpp::Category* parent,
14 log4cpp::Priority::Value priority) :
15 log4cpp::Category(name, parent, priority),
16 log_port( convertName(name) , false )
24 void Category::log(log4cpp::Priority::Value priority,
25 const RTT::rt_string& message)
throw()
27 if (isPriorityEnabled(priority))
29 _logUnconditionally2(priority, message);
33 void Category::debug(
const RTT::rt_string& message)
throw()
35 if (isPriorityEnabled(log4cpp::Priority::DEBUG))
36 _logUnconditionally2(log4cpp::Priority::DEBUG, message);
39 void Category::info(
const RTT::rt_string& message)
throw()
41 if (isPriorityEnabled(log4cpp::Priority::INFO))
42 _logUnconditionally2(log4cpp::Priority::INFO, message);
45 void Category::notice(
const RTT::rt_string& message)
throw()
47 if (isPriorityEnabled(log4cpp::Priority::NOTICE))
48 _logUnconditionally2(log4cpp::Priority::NOTICE, message);
51 void Category::warn(
const RTT::rt_string& message)
throw()
53 if (isPriorityEnabled(log4cpp::Priority::WARN))
54 _logUnconditionally2(log4cpp::Priority::WARN, message);
57 void Category::error(
const RTT::rt_string& message)
throw()
59 if (isPriorityEnabled(log4cpp::Priority::ERROR))
60 _logUnconditionally2(log4cpp::Priority::ERROR, message);
63 void Category::crit(
const RTT::rt_string& message)
throw()
65 if (isPriorityEnabled(log4cpp::Priority::CRIT))
66 _logUnconditionally2(log4cpp::Priority::CRIT, message);
69 void Category::alert(
const RTT::rt_string& message)
throw()
71 if (isPriorityEnabled(log4cpp::Priority::ALERT))
72 _logUnconditionally2(log4cpp::Priority::ALERT, message);
75 void Category::emerg(
const RTT::rt_string& message)
throw()
77 if (isPriorityEnabled(log4cpp::Priority::EMERG))
78 _logUnconditionally2(log4cpp::Priority::EMERG, message);
81 void Category::fatal(
const RTT::rt_string& message)
throw()
83 if (isPriorityEnabled(log4cpp::Priority::FATAL))
84 _logUnconditionally2(log4cpp::Priority::FATAL, message);
89 const RTT::rt_string& message)
throw()
94 RTT::rt_string(message.c_str()),
101 catch (std::bad_alloc& e)
114 if (getAdditivity() && (getParent() != NULL))
127 std::string rc(name);
129 std::replace_if(rc.begin(),
131 std::bind2nd(std::equal_to<char>(),
'.'),
138 log4cpp::Category* parent,
139 log4cpp::Priority::Value priority)
152 priority : log4cpp::Priority::NOTSET);
157 return otherPort.connectTo(&
log_port);
163 return otherPort.connectTo(&
log_port, cp);
A mirror of log4cpp::LoggingEvent, except using real-time capable strings.
static log4cpp::Category * createOCLCategory(const std::string &name, log4cpp::Category *parent, log4cpp::Priority::Value priority)
Factory function for log4cpp::HierarchyMaintainer Creates an OCL logging category.
bool connectToLogPort(RTT::base::PortInterface &otherPort)
Connect otherPort to log_port.
static std::string convertName(const std::string &name)
Convert name into Orocos notation (e.g.
This is a utility class which you can use to stream messages into a category object.
void _logUnconditionally2(log4cpp::Priority::Value priority, const RTT::rt_string &message)
RTT::InputPort< OCL::logging::LoggingEvent > log_port
Port we receive logging events on Initially unconnected.
The Orocos Component Library.
A real-time capable category.
virtual void callAppenders(const OCL::logging::LoggingEvent &event)
Send event to all attached appenders.
CategoryStream getRTStream(log4cpp::Priority::Value priority)
Returns a stream-like object into which you can log arbitrary data which supports the operator<<()...