libgslutil
1.2.3
|
Rate-limiting log details. More...
Data Fields | |
int | max |
Maximum number of entries per period. | |
int | period |
Period (in seconds) over which to ratelimit. Once elapsed, counters are reset. | |
int | num |
Number of entries so far this period. Stops at max. | |
time_t | start |
Absolute time at which first log entry this period was made. | |
Rate-limiting log details.
This structure is used to maintain rate-limited logs. Although it doesn't malfunction in the case of non-monotonic time, it may reset the rate counter. The max and period members must be set to the maximum number of log entries per period seconds. num and start must be initialised to 0.
Whenever a log entry is written, the difference between start and the current time is examined. If the difference is greater than period, then start is set to the current time, num is cleared, and the entry is sent to syslog. If the difference is less than period, then num is incremented, and the entry is only sent to syslog if num is less than max.