FileAppender.cpp
Go to the documentation of this file.
00001 #include "logging/FileAppender.hpp"
00002 #include "ocl/Component.hpp"
00003 #include <rtt/Logger.hpp>
00004 
00005 #include <log4cpp/FileAppender.hh>
00006 
00007 using namespace RTT;
00008 
00009 namespace OCL {
00010 namespace logging {
00011 
00012 FileAppender::FileAppender(std::string name) :
00013                 OCL::logging::Appender(name),
00014         filename_prop("Filename", "Name of file to log to"),
00015         maxEventsPerCycle_prop("MaxEventsPerCycle", "Maximum number of log events to pop per cycle",1),
00016         maxEventsPerCycle(1)
00017 {
00018     properties()->addProperty(filename_prop);
00019     properties()->addProperty(maxEventsPerCycle_prop);
00020 }
00021 
00022 FileAppender::~FileAppender()
00023 {
00024 }
00025 
00026 bool FileAppender::configureHook()
00027 {
00028     // verify valid limits
00029     int m = maxEventsPerCycle_prop.rvalue();
00030     if ((0 > m))
00031     {
00032         log(Error) << "Invalid maxEventsPerCycle value of "
00033                    << m << ". Value must be >= 0."
00034                    << endlog();
00035         return false;
00036     }
00037     maxEventsPerCycle = m;
00038 
00039     // \todo error checking
00040     if (appender)
00041         delete appender; // in case the filename changed...
00042 
00043     appender = new log4cpp::FileAppender(getName(), filename_prop.rvalue());
00044 
00045     return configureLayout();
00046 }
00047 
00048 void FileAppender::updateHook()
00049 {
00050         processEvents(maxEventsPerCycle);
00051 }
00052 
00053 void FileAppender::cleanupHook()
00054 {
00055     /* normally in log4cpp the category owns the appenders and deletes them
00056        itself, however we don't associate appenders and categories in the
00057        same manner. Hence, you have to manually manage appenders.
00058     */
00059     delete appender;
00060     appender = 0;
00061 }
00062 
00063 // namespaces
00064 }
00065 }
00066 
00067 ORO_LIST_COMPONENT_TYPE(OCL::logging::FileAppender);


ocl
Author(s): OCL Development Team
autogenerated on Mon Sep 14 2015 14:21:46