Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding LOG_IF_OR_EVERY_N() #143

Closed
alexsmac opened this issue Dec 5, 2016 · 0 comments
Closed

Adding LOG_IF_OR_EVERY_N() #143

alexsmac opened this issue Dec 5, 2016 · 0 comments

Comments

@alexsmac
Copy link
Contributor

alexsmac commented Dec 5, 2016

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?

@sergiud sergiud closed this as completed Mar 30, 2021
@sergiud sergiud mentioned this issue May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants