RollingFileAppender.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 RollingFileAppender::RollingFileAppender(std::string name) :
13  OCL::logging::Appender(name),
14  filename_prop("Filename", "Name of file to log to"),
15  maxFileSize_prop("MaxFileSize",
16  "Maximum file size (in bytes) before rolling over",
17  10 * 1024 * 1024), // default in log4cpp
18  maxBackupIndex_prop("MaxBackupIndex",
19  "Maximum number of backup files to keep",
20  1), // default in log4cpp
21  maxEventsPerCycle_prop("MaxEventsPerCycle",
22  "Maximum number of log events to pop per cycle",
23  1),
24  maxEventsPerCycle(1)
25 {
30 }
31 
33 {
34 }
35 
37 {
38  // verify valid limits
40  if ((0 > m))
41  {
42  log(Error) << "Invalid maxEventsPerCycle value of "
43  << m << ". Value must be >= 0."
44  << endlog();
45  return false;
46  }
48 
49  // \todo error checking
50 
51  log(Info) << "maxfilesize " << maxFileSize_prop.get()
52  << " maxbackupindex " << maxBackupIndex_prop.get() << std::endl;
57 
58  return configureLayout();
59 }
60 
62 {
64 }
65 
67 {
68  /* normally in log4cpp the category owns the appenders and deletes them
69  itself, however we don't associate appenders and categories in the
70  same manner. Hence, you have to manually manage appenders.
71  */
72  delete appender;
73  appender = 0;
74 }
75 
76 // namespaces
77 }
78 }
79 
DataSourceType get() const
log4cpp::Appender * appender
Appender created by derived class.
Definition: Appender.hpp:52
virtual bool configureHook()
Create log4cpp 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
RTT::Property< int > maxBackupIndex_prop
Maximum number of backup files to keep.
Error
ORO_LIST_COMPONENT_TYPE(OCL::logging::RollingFileAppender)
RTT::Property< std::string > filename_prop
Name of file to append to.
virtual void cleanupHook()
Destroy appender.
RTT::Property< int > maxFileSize_prop
Maximum file size (in bytes) before rolling over.
Info
PropertyBag * properties()
virtual void updateHook()
Process at most maxEventsPerCycle event.
virtual const std::string & getName() const


ocl
Author(s): OCL Development Team
autogenerated on Wed Jun 26 2019 19:26:27