mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 04:52:24 -05:00
[feature] Make client IP logging configurable (#1799)
This commit is contained in:
parent
68e54cbaa4
commit
107237c8e8
9 changed files with 40 additions and 12 deletions
|
|
@ -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(),
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue