fix: include remote IP address in HTTP request logs

This commit is contained in:
kolaente
2026-03-04 23:35:34 +01:00
parent 7288483879
commit f9cb0a2de1

View File

@@ -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),