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

Log errors once #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Log errors once #80

wants to merge 1 commit into from

Conversation

ypft
Copy link

@ypft ypft commented Dec 15, 2024

Hi!

Thank you for your amazing work!
Currently, if in some handler you have more than one (assume n) call to c.Error(someErr), this middleware will create n separate log entries. This might not be a frequent use case, but with Gin, it is possible to do so (and we do in our projects).

In this pull request, I’ve added a LogErrorsOnce config option. If set to false (default), the old behavior remains unchanged. However, if set to true, only one logger.Error(c.Errors.String(), fields...) will be called.

What do you think?

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

Successfully merging this pull request may close these issues.

1 participant