OrocosComponentLibrary
2.7.0
|
00001 #ifndef socketAppender_HPP 00002 #define socketAppender_HPP 1 00003 00004 #include <rtt/TaskContext.hpp> 00005 #include <rtt/Property.hpp> 00006 #include <rtt/InputPort.hpp> 00007 #include "LoggingEvent.hpp" 00008 #include <log4cxx/logger.h> 00009 #include <log4cxx/helpers/pool.h> 00010 #include <log4cxx/basicconfigurator.h> 00011 #include <log4cxx/net/socketappender.h> 00012 #include <log4cxx/simplelayout.h> 00013 00014 #if 0 00015 int main() { 00016 log4cxx::Log4cxxAppender * socketAppender = new 00017 log4cxx::Log4cxxAppender(log4cxx::LayoutPtr(new log4cxx::SimpleLayout()), 00018 "logfile", false); 00019 00020 log4cxx::helpers::Pool p; 00021 socketAppender->activateOptions(p); 00022 00023 log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(socketAppender)); 00024 log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug()); 00025 log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("logger"); 00026 00027 LOG4CXX_INFO(logger,"Created Log4cxxAppender appender"); 00028 00029 return 0; 00030 } 00031 #endif 00032 00033 namespace OCL { 00034 namespace logging { 00035 00040 class Log4cxxAppender 00041 : public RTT::TaskContext 00042 { 00043 public: 00044 Log4cxxAppender(std::string name); 00045 virtual ~Log4cxxAppender(); 00046 protected: 00047 virtual bool configureHook(); 00048 virtual void updateHook(); 00049 virtual void cleanupHook(); 00050 00051 log4cxx::helpers::Pool p; 00052 log4cxx::net::SocketAppender * socketAppender; 00053 log4cxx::helpers::InetAddressPtr address; 00054 00057 RTT::InputPort<OCL::logging::LoggingEvent> log_port; 00058 00060 std::string hostname_prop; 00061 00063 int port_prop; 00067 int maxEventsPerCycle_prop; 00068 00078 int maxEventsPerCycle; 00079 }; 00080 00081 // namespaces 00082 } 00083 } 00084 00085 #endif