[feature] attach any request errors if found, only set level=ERROR if code >= 500 (#2300)

This commit is contained in:
kim 2023-10-25 16:11:40 +01:00 committed by GitHub
parent c7b6cd7770
commit ece2e795e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,9 +87,13 @@ func Logger(logClientIP bool) gin.HandlerFunc {
lvl := level.INFO
if code >= 500 {
// This is a server error
// Actual server error.
lvl = level.ERROR
l = l.WithField("error", c.Errors)
}
if len(c.Errors) > 0 {
// Always attach any found errors.
l = l.WithField("errors", c.Errors)
}
// Get appropriate text for this code.