summaryrefslogtreecommitdiff
path: root/internal/middleware
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-10-25 16:11:40 +0100
committerLibravatar GitHub <noreply@github.com>2023-10-25 16:11:40 +0100
commitece2e795e0b9151991e36f1cb173e43066c8959c (patch)
treecdcdfb13bb32f249f92bd560cd219134dd5d25d4 /internal/middleware
parent[feature] Status thread mute/unmute functionality (#2278) (diff)
downloadgotosocial-ece2e795e0b9151991e36f1cb173e43066c8959c.tar.xz
[feature] attach any request errors if found, only set level=ERROR if code >= 500 (#2300)
Diffstat (limited to 'internal/middleware')
-rw-r--r--internal/middleware/logger.go8
1 files 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.