Description
I'm wondering what the interest is in accepting a PR adding: LOG_IF_OR_EVERY_N(). My use case for this is something like the following:
while (...) {
try {
// Do work.
...
previous_iteration_was_successful_ = true;
} catch (...) {
LOG_IF_OR_EVERY_N(WARNING, previous_iteration_was_successful_, 10)
<< "Failed to do work.";
previous_iteration_was_successful_ = false;
}
}
where I always want to LOG() the first failure after a success, but if we keep failing then I only want to LOG() every n-th failure. This is important to highlight in the log output when sporadic failures start after a long run of successes (expected behaviour), irrespective of the modulo count of the total number of previous failures whilst still not overloading the log output if failures repeatedly occur in a sequence.
This is obviously pretty trivial to add, as it essentially involves substituting || for && in a replicated version of SOME_KIND_OF_LOG_IF_EVERY_N() and I've done this and it works as expected. Is this something that would be accepted back into master?
Activity