Skip to content

Commit

Permalink
[feature] attach any request errors if found, only set level=ERROR if…
Browse files Browse the repository at this point in the history
… code >= 500 (#2300)
  • Loading branch information
NyaaaWhatsUpDoc committed Oct 25, 2023
1 parent c7b6cd7 commit ece2e79
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/middleware/logger.go
Expand Up @@ -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.
Expand Down

0 comments on commit ece2e79

Please sign in to comment.