PTLib
Version 2.18.8
|
Class to reduce noise level for some logging. More...
#include <object.h>
Public Member Functions | |
ThrottleBase (unsigned lowLevel, unsigned interval=60000, unsigned highLevel=6, unsigned maxShown=1) | |
ThrottleBase (const ThrottleBase &other) | |
ThrottleBase & | operator= (const ThrottleBase &other) |
bool | CanTrace (int64_t now=0) |
operator unsigned () const | |
__inline unsigned | GetLowLevel () const |
__inline unsigned | GetHighLevel () const |
__inline unsigned | GetCurrentLevel () const |
__inline unsigned | GetHiddenCount () const |
Protected Attributes | |
unsigned | m_interval |
unsigned | m_lowLevel |
unsigned | m_highLevel |
unsigned | m_maxShown |
atomic< unsigned > | m_currentLevel |
atomic< int64_t > | m_nextLog |
atomic< unsigned > | m_repeatCount |
atomic< unsigned > | m_hiddenCount |
Friends | |
ostream & | operator<< (ostream &strm, const ThrottleBase &throttle) |
Class to reduce noise level for some logging.
A log is emitted at the lowLevel every interval milliseconds. All logs within the time interval are emitted at highLevel.
An optional log output of the count of times the log occurred during may achived by simply including the throttle instance at the end of the log, e.g.
PTRACE_THROTTLE_STATIC(m_throttleIt, 2, 2000);
PTRACE(m_throttleIt, "A very frequent log" << m_throttleIt);
The maxShown parameter indicates the maximum number of trace outputs that can occur in the time interval.
Additional note: the "repeated" count optionally output is not 100% accurate in multi-threaded usage.
PTrace::ThrottleBase::ThrottleBase | ( | unsigned | lowLevel, |
unsigned | interval = 60000 , |
||
unsigned | highLevel = 6 , |
||
unsigned | maxShown = 1 |
||
) |
lowLevel | Level at which low frequency logs made |
interval | Time between low frequency logs |
highLevel | Level for high frequency (every) logs |
maxShown | Max shown messages in time interval |
PTrace::ThrottleBase::ThrottleBase | ( | const ThrottleBase & | other | ) |
bool PTrace::ThrottleBase::CanTrace | ( | int64_t | now = 0 | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
ThrottleBase& PTrace::ThrottleBase::operator= | ( | const ThrottleBase & | other | ) |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |