fix: include remote IP address in HTTP request logs
This commit is contained in:
parent
7288483879
commit
f9cb0a2de1
|
|
@ -135,10 +135,12 @@ func NewEcho() *echo.Echo {
|
|||
LogURI: true,
|
||||
LogMethod: true,
|
||||
LogLatency: true,
|
||||
LogRemoteIP: true,
|
||||
HandleError: true,
|
||||
LogValuesFunc: func(_ *echo.Context, v middleware.RequestLoggerValues) error {
|
||||
if v.Error == nil {
|
||||
httpLogger.LogAttrs(context.Background(), slog.LevelInfo, "",
|
||||
slog.String("remote_ip", v.RemoteIP),
|
||||
slog.String("method", v.Method),
|
||||
slog.String("uri", v.URI),
|
||||
slog.Int("status", v.Status),
|
||||
|
|
@ -146,6 +148,7 @@ func NewEcho() *echo.Echo {
|
|||
)
|
||||
} else {
|
||||
httpLogger.LogAttrs(context.Background(), slog.LevelError, "",
|
||||
slog.String("remote_ip", v.RemoteIP),
|
||||
slog.String("method", v.Method),
|
||||
slog.String("uri", v.URI),
|
||||
slog.Int("status", v.Status),
|
||||
|
|
|
|||
Loading…
Reference in New Issue