$search
00001 #include "logging/OstreamAppender.hpp" 00002 #include "ocl/Component.hpp" 00003 00004 #include <log4cpp/OstreamAppender.hh> 00005 00006 namespace OCL { 00007 namespace logging { 00008 00009 OstreamAppender::OstreamAppender(std::string name) : 00010 OCL::logging::Appender(name) 00011 { 00012 } 00013 00014 OstreamAppender::~OstreamAppender() 00015 { 00016 } 00017 00018 bool OstreamAppender::configureHook() 00019 { 00020 appender = new log4cpp::OstreamAppender(getName(), &std::cout); 00021 00022 return configureLayout(); 00023 } 00024 00025 void OstreamAppender::updateHook() 00026 { 00027 if (!log_port.connected()) return; // no category connected to us 00028 00029 OCL::logging::LoggingEvent event; 00030 if (log_port.read( event ) == RTT::NewData) 00031 { 00032 log4cpp::LoggingEvent e2 = event.toLog4cpp(); 00033 assert(appender); 00034 appender->doAppend(e2); 00035 } 00036 } 00037 00038 void OstreamAppender::cleanupHook() 00039 { 00040 delete appender; 00041 appender = 0; 00042 } 00043 00044 // namespaces 00045 } 00046 } 00047 00048 ORO_LIST_COMPONENT_TYPE(OCL::logging::OstreamAppender);