auth/transcoder: associates the echo logs with request context (#1256)

This commit is contained in:
acelinkio 2026-01-05 00:21:25 -08:00 committed by GitHub
parent 65784f38dd
commit a09d8f45b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -272,8 +272,9 @@ func main() {
LogUserAgent: true,
HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
rCtx := c.Request().Context()
if v.Error == nil {
logger.LogAttrs(ctx, slog.LevelInfo, "web_request",
logger.LogAttrs(rCtx, slog.LevelInfo, "web_request",
slog.String("method", v.Method),
slog.Int("status", v.Status),
slog.String("host", v.Host),
@ -281,7 +282,7 @@ func main() {
slog.String("agent", v.UserAgent),
)
} else {
logger.LogAttrs(ctx, slog.LevelError, "web_request_error",
logger.LogAttrs(rCtx, slog.LevelError, "web_request_error",
slog.String("method", v.Method),
slog.Int("status", v.Status),
slog.String("host", v.Host),

View File

@ -132,8 +132,9 @@ func main() {
LogUserAgent: true,
HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
rCtx := c.Request().Context()
if v.Error == nil {
logger.LogAttrs(ctx, slog.LevelInfo, "web_request",
logger.LogAttrs(rCtx, slog.LevelInfo, "web_request",
slog.String("method", v.Method),
slog.Int("status", v.Status),
slog.String("host", v.Host),
@ -141,7 +142,7 @@ func main() {
slog.String("agent", v.UserAgent),
)
} else {
logger.LogAttrs(ctx, slog.LevelError, "web_request_error",
logger.LogAttrs(rCtx, slog.LevelError, "web_request_error",
slog.String("method", v.Method),
slog.Int("status", v.Status),
slog.String("host", v.Host),