From ece2e795e0b9151991e36f1cb173e43066c8959c Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:11:40 +0100 Subject: [PATCH] [feature] attach any request errors if found, only set level=ERROR if code >= 500 (#2300) --- internal/middleware/logger.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/middleware/logger.go b/internal/middleware/logger.go index 58f90b088..f9b81d58a 100644 --- a/internal/middleware/logger.go +++ b/internal/middleware/logger.go @@ -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.