Skip to content

Commit 1659288

Browse files
authored
Merge pull request #535 from alfrunes/accesslog-logger
chore: Initialize requestlogger in accesslog middleware (gin)
2 parents f5ff994 + a56a79e commit 1659288

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

backend/pkg/accesslog/middleware_gin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,14 @@ func (a AccessLogger) LogFunc(
117117
Log(logLevel)
118118
}
119119

120+
// Middleware implementsa gin compatible MiddlewareFunc
121+
//
122+
// NOTE: This accesslog middleware also implements the legacy requestlog
123+
// middleware.
120124
func (a AccessLogger) Middleware(c *gin.Context) {
121125
ctx := c.Request.Context()
122126
startTime := time.Now()
127+
ctx = log.WithContext(ctx, log.New(log.Ctx{}))
123128
ctx = withContext(ctx, &logContext{maxErrors: DefaultMaxErrors})
124129
c.Request = c.Request.WithContext(ctx)
125130
defer a.LogFunc(ctx, c, startTime)

0 commit comments

Comments
 (0)