mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-04-20 08:49:17 -04:00
auth/transcoder: associates the echo logs with request context (#1256)
This commit is contained in:
parent
65784f38dd
commit
a09d8f45b9
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user