Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
logging
FileAppender.cpp
Go to the documentation of this file.
1
#include "
logging/FileAppender.hpp
"
2
#include "
ocl/Component.hpp
"
3
#include <
rtt/Logger.hpp
>
4
5
#include <
log4cpp/FileAppender.hh
>
6
7
using namespace
RTT
;
8
9
namespace
OCL
{
10
namespace
logging {
11
12
FileAppender::FileAppender(std::string name) :
13
OCL
::logging::
Appender
(name),
14
filename_prop(
"Filename"
,
"Name of file to log to"
),
15
maxEventsPerCycle_prop(
"MaxEventsPerCycle"
,
"Maximum number of log events to pop per cycle"
,1),
16
maxEventsPerCycle(1)
17
{
18
properties
()->
addProperty
(
filename_prop
);
19
properties
()->
addProperty
(
maxEventsPerCycle_prop
);
20
}
21
22
FileAppender::~FileAppender
()
23
{
24
}
25
26
bool
FileAppender::configureHook
()
27
{
28
// verify valid limits
29
int
m =
maxEventsPerCycle_prop
.
rvalue
();
30
if
((0 > m))
31
{
32
log(
Error
) <<
"Invalid maxEventsPerCycle value of "
33
<< m <<
". Value must be >= 0."
34
<< endlog();
35
return
false
;
36
}
37
maxEventsPerCycle
= m;
38
39
// \todo error checking
40
if
(
appender
)
41
delete
appender
;
// in case the filename changed...
42
43
appender
=
new
log4cpp::FileAppender
(
getName
(),
filename_prop
.
rvalue
());
44
45
return
configureLayout
();
46
}
47
48
void
FileAppender::updateHook
()
49
{
50
processEvents
(
maxEventsPerCycle
);
51
}
52
53
void
FileAppender::cleanupHook
()
54
{
55
/* normally in log4cpp the category owns the appenders and deletes them
56
itself, however we don't associate appenders and categories in the
57
same manner. Hence, you have to manually manage appenders.
58
*/
59
delete
appender
;
60
appender
= 0;
61
}
62
63
// namespaces
64
}
65
}
66
67
ORO_LIST_COMPONENT_TYPE
(
OCL::logging::FileAppender
);
OCL::logging::FileAppender::filename_prop
RTT::Property< std::string > filename_prop
Name of file to append to.
Definition:
FileAppender.hpp:24
OCL::logging::FileAppender::maxEventsPerCycle
int maxEventsPerCycle
Definition:
FileAppender.hpp:39
OCL::logging::Appender::appender
log4cpp::Appender * appender
Appender created by derived class.
Definition:
Appender.hpp:52
log4cpp::FileAppender
OCL::logging::FileAppender::configureHook
virtual bool configureHook()
Create log4cpp appender.
Definition:
FileAppender.cpp:26
OCL::logging::FileAppender::maxEventsPerCycle_prop
RTT::Property< int > maxEventsPerCycle_prop
Definition:
FileAppender.hpp:28
RTT::Property::rvalue
const_reference_t rvalue() const
OCL::logging::Appender
Definition:
Appender.hpp:16
Logger.hpp
Component.hpp
ORO_LIST_COMPONENT_TYPE
ORO_LIST_COMPONENT_TYPE(OCL::logging::FileAppender)
FileAppender.hpp
OCL::logging::Appender::configureLayout
virtual bool configureLayout()
Definition:
Appender.cpp:29
RTT::PropertyBag::addProperty
Property< T > & addProperty(const std::string &name, T &attr)
OCL
Definition:
deployer-funcs.cpp:68
OCL::logging::Appender::processEvents
virtual void processEvents(int n)
Definition:
Appender.cpp:104
OCL::logging::FileAppender::~FileAppender
virtual ~FileAppender()
Definition:
FileAppender.cpp:22
Error
Error
RTT::TaskContext::properties
PropertyBag * properties()
RTT
FileAppender.hh
OCL::logging::FileAppender
Definition:
FileAppender.hpp:10
OCL::logging::FileAppender::cleanupHook
virtual void cleanupHook()
Destroy appender.
Definition:
FileAppender.cpp:53
RTT::TaskContext::getName
virtual const std::string & getName() const
OCL::logging::FileAppender::updateHook
virtual void updateHook()
Process at most maxEventsPerCycle event.
Definition:
FileAppender.cpp:48
ocl
Author(s): OCL Development Team
autogenerated on Wed Jun 26 2019 19:26:27