GenerationalFileAppender.cpp
Go to the documentation of this file.
2 #include "ocl/Component.hpp"
3 #include <rtt/Logger.hpp>
4 
6 
7 using namespace RTT;
8 
9 namespace OCL {
10 namespace logging {
11 
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",
18  1),
19  maxEventsPerCycle(1)
20 {
21  provides()->addOperation(advanceGeneration_op).doc("Advance to the next logfile generation");
22 
25 }
26 
28 {
29 }
30 
32 {
33  // verify valid limits
35  if ((0 > m))
36  {
37  log(Error) << "Invalid maxEventsPerCycle value of "
38  << m << ". Value must be >= 0."
39  << endlog();
40  return false;
41  }
43 
44  // \todo error checking
45 
47  filename_prop.get());
48 
49  return configureLayout();
50 }
51 
53 {
55 }
56 
58 {
59  /* normally in log4cpp the category owns the appenders and deletes them
60  itself, however we don't associate appenders and categories in the
61  same manner. Hence, you have to manually manage appenders.
62  */
63  delete appender;
64  appender = 0;
65 }
66 
68 {
69  if (0 != appender)
70  {
72  }
73  else
74  {
75  log(Error) << "No appender to roll over!" << endlog();
76  }
77 }
78 
79 // namespaces
80 }
81 }
82 
virtual bool configureHook()
Create log4cpp appender.
DataSourceType get() const
log4cpp::Appender * appender
Appender created by derived class.
Definition: Appender.hpp:52
Service::shared_ptr provides()
virtual void cleanupHook()
Destroy appender.
const_reference_t rvalue() const
virtual bool configureLayout()
Definition: Appender.cpp:29
Property< T > & addProperty(const std::string &name, T &attr)
virtual void processEvents(int n)
Definition: Appender.cpp:104
void advanceGeneration()
Advance to the next logfile generation.
Error
PropertyBag * properties()
ORO_LIST_COMPONENT_TYPE(OCL::logging::GenerationalFileAppender)
virtual void updateHook()
Process at most maxEventsPerCycle event.
RTT::Property< std::string > filename_prop
Name of file to append to.
virtual const std::string & getName() const


ocl
Author(s): OCL Development Team
autogenerated on Mon Mar 23 2020 04:47:19