Vault  4.1
Public Member Functions
VLoggerRepetitionFilter Class Reference

VLoggerRepetitionFilter provides VLogger a simple way of preventing runaway repetitive log output. More...

#include <vlogger.h>

List of all members.

Public Member Functions

void setEnabled (bool enabled)
 Some VLogger subclasses may want to simply disable filtering.
bool isEnabled () const
 Returns true if the filter is enabled.
void reset ()
 Clears any pending message so that the filter is back to an initial state.
bool checkMessage (VNamedLogger &logger, int level, const char *file, int line, const VString &message, const VString &specifiedLoggerName, const VString &actualLoggerName)
 Checks the proposed log message; may save it or increment the internal counter; may emit a pending saved message; returns true if the caller should proceed to emit the message normally.
void checkTimeout (VNamedLogger &logger)
 Checks to see if a long time has elapsed since the pending repeat has been sitting here.

Detailed Description

VLoggerRepetitionFilter provides VLogger a simple way of preventing runaway repetitive log output.

If the same text is emitted at the same level multiple times in succession, only the first and last occurrences are emitted (the last one is adorned with an indication of how many occurrences were suppressed, if any).

Definition at line 397 of file vlogger.h.


Member Function Documentation

void VLoggerRepetitionFilter::setEnabled ( bool  enabled) [inline]

Some VLogger subclasses may want to simply disable filtering.

This allows them to do so in their constructor, for example.

Parameters:
enabledtrue if enabling, false if disabling

Definition at line 408 of file vlogger.h.

bool VLoggerRepetitionFilter::isEnabled ( ) const [inline]

Returns true if the filter is enabled.

Returns:
true if the filter is enabled

Definition at line 413 of file vlogger.h.

void VLoggerRepetitionFilter::reset ( )

Clears any pending message so that the filter is back to an initial state.

This does not change the enabled state.

Definition at line 1293 of file vlogger.cpp.

References VString::EMPTY(), VInstant::NEVER_OCCURRED(), and NULL.

bool VLoggerRepetitionFilter::checkMessage ( VNamedLogger logger,
int  level,
const char *  file,
int  line,
const VString message,
const VString specifiedLoggerName,
const VString actualLoggerName 
)

Checks the proposed log message; may save it or increment the internal counter; may emit a pending saved message; returns true if the caller should proceed to emit the message normally.

Parameters:
loggerthe logger to which any backlog of messages will be emitted
levelthe level of detail of the message
filethe file name that is emitting the log message; NULL will suppress file and line in output
linethe line number that is emitting the log message
messagethe text to emit
specifiedLoggerNameif not empty, the logger name supplied by original caller
actualLoggerNameif not empty, the logger name that is actually calling us
Returns:
true if the caller should proceed to emit this message, false if not

Definition at line 1305 of file vlogger.cpp.

References VInstant::setNow().

void VLoggerRepetitionFilter::checkTimeout ( VNamedLogger logger)

Checks to see if a long time has elapsed since the pending repeat has been sitting here.

This is called by the logger before checking the log level. This prevents the case where a repeat never gets output just because there's nothing after it that fits the log level.

Parameters:
loggerthe logger to which any backlog of messages will be emitted

Definition at line 1347 of file vlogger.cpp.

References VDuration::MINUTE().


The documentation for this class was generated from the following files:

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.