OrocosComponentLibrary  2.8.3
Log4cxxAppender.hpp
1 #ifndef socketAppender_HPP
2 #define socketAppender_HPP 1
3 
4 #include <rtt/TaskContext.hpp>
5 #include <rtt/Property.hpp>
6 #include <rtt/InputPort.hpp>
7 #include "LoggingEvent.hpp"
8 #include <log4cxx/logger.h>
9 #include <log4cxx/helpers/pool.h>
10 #include <log4cxx/basicconfigurator.h>
11 #include <log4cxx/net/socketappender.h>
12 #include <log4cxx/simplelayout.h>
13 
14 #if 0
15 int main() {
16  log4cxx::Log4cxxAppender * socketAppender = new
17 log4cxx::Log4cxxAppender(log4cxx::LayoutPtr(new log4cxx::SimpleLayout()),
18 "logfile", false);
19 
20  log4cxx::helpers::Pool p;
21  socketAppender->activateOptions(p);
22 
23  log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(socketAppender));
24  log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug());
25  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("logger");
26 
27  LOG4CXX_INFO(logger,"Created Log4cxxAppender appender");
28 
29  return 0;
30 }
31 #endif
32 
33 namespace OCL {
34 namespace logging {
35 
41  : public RTT::TaskContext
42 {
43 public:
44  Log4cxxAppender(std::string name);
45  virtual ~Log4cxxAppender();
46 protected:
47  virtual bool configureHook();
48  virtual void updateHook();
49  virtual void cleanupHook();
50 
51  log4cxx::helpers::Pool p;
52  log4cxx::net::SocketAppender * socketAppender;
53  log4cxx::helpers::InetAddressPtr address;
54 
57  RTT::InputPort<OCL::logging::LoggingEvent> log_port;
58 
60  std::string hostname_prop;
61 
63  int port_prop;
68 
79 };
80 
81 // namespaces
82 }
83 }
84 
85 #endif
Interoperability component which translates our log4cpp events to log4cxx events and sends them to a ...
int maxEventsPerCycle_prop
Property to set maximum number of log events to pop per cycle.
int maxEventsPerCycle
Maximum number of log events to pop per cycle.
The Orocos Component Library.
Definition: Component.hpp:43
RTT::InputPort< OCL::logging::LoggingEvent > log_port
Port we receive logging events on Initially unconnected.
int port_prop
The port where the logging server runs.
std::string hostname_prop
Name of host to append to.