mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-08-15 18:45:24 +00:00
auth/transcoder: associates the echo logs with request context (#1256)
This commit is contained in:
+3
-2
@@ -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),
|
||||
|
||||
+3
-2
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user