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
00036 class Log4cxxAppender
00037 : public RTT::TaskContext
00038 {
00039 public:
00040 Log4cxxAppender(std::string name);
00041 virtual ~Log4cxxAppender();
00042 protected:
00043 virtual bool configureHook();
00044 virtual void updateHook();
00045 virtual void cleanupHook();
00046
00047 log4cxx::helpers::Pool p;
00048 log4cxx::net::SocketAppender * socketAppender;
00049 log4cxx::helpers::InetAddressPtr address;
00050
00053 RTT::InputPort<OCL::logging::LoggingEvent> log_port;
00054
00056 std::string hostname_prop;
00057
00059 int port_prop;
00063 int maxEventsPerCycle_prop;
00064
00074 int maxEventsPerCycle;
00075 };
00076
00077
00078 }
00079 }
00080
00081 #endif