diff options
author | 2023-05-21 17:12:47 +0200 | |
---|---|---|
committer | 2023-05-21 16:12:47 +0100 | |
commit | 107237c8e84c541d7f24095dcce7abaf5d973a7e (patch) | |
tree | b8721da6c56172dad5bb290516f7a0526bbc2236 /internal/middleware/logger.go | |
parent | [bugfix] Start + stop caches properly for testrig + pruning (#1804) (diff) | |
download | gotosocial-107237c8e84c541d7f24095dcce7abaf5d973a7e.tar.xz |
[feature] Make client IP logging configurable (#1799)
Diffstat (limited to 'internal/middleware/logger.go')
-rw-r--r-- | internal/middleware/logger.go | 7 |
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(), }) |