summaryrefslogtreecommitdiff
path: root/internal/middleware/logger.go
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2023-05-21 17:12:47 +0200
committerLibravatar GitHub <noreply@github.com>2023-05-21 16:12:47 +0100
commit107237c8e84c541d7f24095dcce7abaf5d973a7e (patch)
treeb8721da6c56172dad5bb290516f7a0526bbc2236 /internal/middleware/logger.go
parent[bugfix] Start + stop caches properly for testrig + pruning (#1804) (diff)
downloadgotosocial-107237c8e84c541d7f24095dcce7abaf5d973a7e.tar.xz
[feature] Make client IP logging configurable (#1799)
Diffstat (limited to 'internal/middleware/logger.go')
-rw-r--r--internal/middleware/logger.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/internal/middleware/logger.go b/internal/middleware/logger.go
index 50e5542c3..8acb742fb 100644
--- a/internal/middleware/logger.go
+++ b/internal/middleware/logger.go
@@ -31,7 +31,7 @@ import (
)
// Logger returns a gin middleware which provides request logging and panic recovery.
-func Logger() gin.HandlerFunc {
+func Logger(logClientIP bool) gin.HandlerFunc {
return func(c *gin.Context) {
// Initialize the logging fields
fields := make(kv.Fields, 5, 7)
@@ -72,10 +72,7 @@ func Logger() gin.HandlerFunc {
fields[2] = kv.Field{"method", c.Request.Method}
fields[3] = kv.Field{"statusCode", code}
fields[4] = kv.Field{"path", path}
- if includeClientIP := true; includeClientIP {
- // TODO: make this configurable.
- //
- // Include clientIP if enabled.
+ if logClientIP {
fields = append(fields, kv.Field{
"clientIP", c.ClientIP(),
})