1 #include "logging/GenerationalFileAppender.hpp" 3 #include <rtt/Logger.hpp> 5 #include <log4cpp/GenerationalFileAppender.hh> 12 GenerationalFileAppender::GenerationalFileAppender(std::string name) :
13 OCL::logging::Appender(name),
14 advanceGeneration_op(
"advanceGeneration", &GenerationalFileAppender::advanceGeneration, this,
RTT::OwnThread),
15 filename_prop(
"Filename",
"Name of file to log to"),
16 maxEventsPerCycle_prop(
"MaxEventsPerCycle",
17 "Maximum number of log events to pop per cycle",
21 provides()->addOperation(advanceGeneration_op).doc(
"Advance to the next logfile generation");
23 properties()->addProperty(filename_prop);
24 properties()->addProperty(maxEventsPerCycle_prop);
27 GenerationalFileAppender::~GenerationalFileAppender()
31 bool GenerationalFileAppender::configureHook()
34 int m = maxEventsPerCycle_prop.rvalue();
37 log(Error) <<
"Invalid maxEventsPerCycle value of " 38 << m <<
". Value must be >= 0." 42 maxEventsPerCycle = m;
46 appender =
new log4cpp::GenerationalFileAppender(getName(),
49 return configureLayout();
52 void GenerationalFileAppender::updateHook()
54 processEvents(maxEventsPerCycle);
57 void GenerationalFileAppender::cleanupHook()
67 void GenerationalFileAppender::advanceGeneration()
71 static_cast<log4cpp::GenerationalFileAppender*
>(appender)->advanceGeneration();
75 log(Error) <<
"No appender to roll over!" << endlog();
This file contains the macros and definitions to create dynamically loadable components.
The Orocos Component Library.
Appender supporting generations of log files.