Skip to content

Commit 0f48372

Browse files
authored
fix(logging): record canceled contexts as 499 (#2176)
1 parent f6280fe commit 0f48372

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/shared/pkg/middleware/logging.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ func LoggingMiddleware(logger logger.Logger, conf Config) gin.HandlerFunc {
7373
}
7474

7575
status := c.Writer.Status()
76+
if errors.Is(ctx.Err(), context.Canceled) {
77+
status = 499
78+
}
7679

7780
fields := []zapcore.Field{
7881
zap.Int("status", status),
@@ -102,7 +105,7 @@ func LoggingMiddleware(logger logger.Logger, conf Config) gin.HandlerFunc {
102105

103106
level := conf.DefaultLevel
104107
switch {
105-
case status >= http.StatusInternalServerError && !errors.Is(ctx.Err(), context.Canceled):
108+
case status >= http.StatusInternalServerError:
106109
level = zapcore.ErrorLevel
107110
case status >= http.StatusBadRequest:
108111
level = zapcore.WarnLevel

0 commit comments

Comments
 (0)