Logging::RepeatGuardLogger

NAME
SYNOPSIS
Detailed Description
Constructor & Destructor Documentation
Member Function Documentation
Author

NAME

Logging::RepeatGuardLogger −

Guard template class against log repetitions.

SYNOPSIS

#include <RepeatGuardLogger.h>

Inherits RepeatGuard.

Public Member Functions

RepeatGuardLogger (ACS::TimeInterval interval, unsigned int maxRepetitions=0)

virtual ~RepeatGuardLogger ()

void log (ALogger &logger)

void log (Logging::Logger::LoggerSmartPtr &logger, Logging::BaseLog::Priority priority, const std::string &message, const std::string &file, unsigned long line, const std::string &method)

void log (Logging::Logger::LoggerSmartPtr &logger, const Logging::BaseLog::LogRecord &lr)

void logAndIncrement (ALogger &logger)

void logAndIncrement (Logging::Logger::LoggerSmartPtr &logger, Logging::BaseLog::Priority priority, const std::string &message, const std::string &file, unsigned long line, const std::string &method)

void logAndIncrement (Logging::Logger::LoggerSmartPtr &logger, const Logging::BaseLog::LogRecord &lr)

Detailed Description

template<class ALogger> class Logging::RepeatGuardLogger< ALogger >

Guard template class against log repetitions.

This is a template class for guarding logs against logging too often. It inherits from RepeatGuard and adds different implementations of the log() method.

In all cases the log() method checks the guarding condition and, if it is the case, forwards the log() command to the given underlying logger object.

Before doing this, it adds the repeatCount additional data field to the log to notify that repeated logs have been skipped according to the guard condition.

Notes:

1. The implementation of the template exploits ’partial template instantiation’ (see Alexandrescu, Modern C++ Design, 1.8). The three signatures for the log() method are not supported by all loggers. What is important is that the log() signarues called for each specific instantiation of the template are supported.

Notice that the log() methods cannot be virtual, otherwise partial template instantiation would not work.

2. The logger object is passed as argument of the log method and not in the constructor of the guard to allow using the same guard with multiple loggers. This (in my opinion) extremely useful additionl flexibility comes to the price of one additional parameter in the function call.

3. Now only the log() method is implemented. This automaticaly increments the ocunter. It would be probably much better to have instead two methods (as was in the original design):

log()

logAndIncrement() Can you confirm this? If nobody vote against, I will add the methods.

4. Here and in the base RepeatGuard class, the interval time is an integer in seconds. For consistency with the other interfaces it should be instead a TimeInterval (long long in 100ns()) as defined in acscommon.idl. If nobody vote against, I will change the signature.

Constructor & Destructor Documentation

template<class ALogger > Logging::RepeatGuardLogger< ALogger >::RepeatGuardLogger (ACS::TimeInterval interval, unsigned int maxRepetitions = 0) Constructor

Parameters:

interval minimum interval between allowing an action (i.e. check returns true)
maxRepetitions
override minimum interval if maxRepetitions is reached.(0 disables this feature)

template<class ALogger > Logging::RepeatGuardLogger< ALogger >::~RepeatGuardLogger () [virtual]

Member Function Documentation

template<class ALogger> void Logging::RepeatGuardLogger< ALogger >::log (ALogger & logger)

References LoggingProxy::AddData(), RepeatGuard::check(), and RepeatGuard::count().

template<class ALogger> void Logging::RepeatGuardLogger< ALogger >::log (Logging::Logger::LoggerSmartPtr & logger, Logging::BaseLog::Priority priority, const std::string & message, const std::string & file, unsigned long line, const std::string & method)

References LoggingProxy::AddData(), RepeatGuard::check(), and RepeatGuard::count().

template<class ALogger> void Logging::RepeatGuardLogger< ALogger >::log (Logging::Logger::LoggerSmartPtr & logger, const Logging::BaseLog::LogRecord & lr)

References LoggingProxy::AddData(), RepeatGuard::check(), and RepeatGuard::count().

template<class ALogger> void Logging::RepeatGuardLogger< ALogger >::logAndIncrement (ALogger & logger)

References LoggingProxy::AddData(), RepeatGuard::checkAndIncrement(), and RepeatGuard::count().

template<class ALogger> void Logging::RepeatGuardLogger< ALogger >::logAndIncrement (Logging::Logger::LoggerSmartPtr & logger, Logging::BaseLog::Priority priority, const std::string & message, const std::string & file, unsigned long line, const std::string & method)

References LoggingProxy::AddData(), RepeatGuard::checkAndIncrement(), and RepeatGuard::count().

template<class ALogger> void Logging::RepeatGuardLogger< ALogger >::logAndIncrement (Logging::Logger::LoggerSmartPtr & logger, const Logging::BaseLog::LogRecord & lr)

References LoggingProxy::AddData(), RepeatGuard::checkAndIncrement(), and RepeatGuard::count().

Author

Generated automatically by Doxygen for ACS-2015.2 C++ API from the source code.