-
Notifications
You must be signed in to change notification settings - Fork 269
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
Decrease log level for 4xx HTTP errors : alternative option #1304
Decrease log level for 4xx HTTP errors : alternative option #1304
Conversation
Can someone tell me why the tests are failing ? I think it's about port already in use, so it could be related to: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you missed adding the LogLevel()
method to the errors of the http
package. Without that all the http errors will be printed at ERROR level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am doubtful and not convinced.
Right now, all the errors are logged at error level, will it be really beneficial from the user perspective to write a method to set the log level for their errors.
Because errors should be logged at error levels or based on the status code.
I.E 4xx being logged at INFO
In my opinion, since all 4xx logs are client-side errors, they are not actually errors related to the server and should be logged at the INFO level like 2xx logs. Just 5xx logs should be considered errors for the server as they are unexpected and server-side errors. |
Indeed, I might have forgotten to commit a local file 🤦♂️😅 I will take a look. |
Exactly, having a distinct error level for http error is important. For example 404 could be a Debug, a 403 could be a warning. A custom error could have a need to set the log level, the same way they are allowed to have a custom status code. But also please note the change allows providing a log level to any error in the stack |
6399b33
to
2c3c779
Compare
Pull Request Template
Description:
This PR is an alternative implementation of what was initiated with
It goes further than #1298 as it allows defining the log level for any error, not only the HTTP errors
It also provides a way for user to provide a log level for their custom errors (See docs/advanced-guide/gofr-errors/page.md)
Fixes #1279
Replaces #1295
Replaces #1298
Checklist:
goimport
andgolangci-lint
.