From 20e04f4fcba0a5ee00fab3d925dadbff2017f80c Mon Sep 17 00:00:00 2001 From: Tink bot Date: Thu, 21 May 2026 13:28:55 +0000 Subject: [PATCH] feat(logging): include user agent in HTTP access log --- pkg/routes/routes.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index 353a1b750..e72d9ec61 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -157,12 +157,13 @@ func NewEcho() *echo.Echo { if config.LogEnabled.GetBool() && config.LogHTTP.GetString() != "off" { httpLogger := log.NewHTTPLogger(config.LogEnabled.GetBool(), config.LogHTTP.GetString(), config.LogFormat.GetString()) e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{ - LogStatus: true, - LogURI: true, - LogMethod: true, - LogLatency: true, - LogRemoteIP: true, - HandleError: true, + LogStatus: true, + LogURI: true, + LogMethod: true, + LogLatency: true, + LogRemoteIP: true, + LogUserAgent: true, + HandleError: true, LogValuesFunc: func(_ *echo.Context, v middleware.RequestLoggerValues) error { if v.Error == nil { httpLogger.LogAttrs(context.Background(), slog.LevelInfo, "", @@ -171,6 +172,7 @@ func NewEcho() *echo.Echo { slog.String("uri", v.URI), slog.Int("status", v.Status), slog.Duration("latency", v.Latency), + slog.String("user_agent", v.UserAgent), ) } else { httpLogger.LogAttrs(context.Background(), slog.LevelError, "", @@ -179,6 +181,7 @@ func NewEcho() *echo.Echo { slog.String("uri", v.URI), slog.Int("status", v.Status), slog.Duration("latency", v.Latency), + slog.String("user_agent", v.UserAgent), slog.String("err", v.Error.Error()), ) }