common: fix unclosed logrus logging pipes

This commit is contained in:
Lukas Zapletal 2025-05-22 13:44:42 +02:00 committed by Lukáš Zapletal
parent 0c325137cf
commit 1cde7e341b
4 changed files with 67 additions and 36 deletions

View file

@ -8,11 +8,10 @@ import (
// Store context in request logger to propagate correlation ids
func LoggerMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
c.SetLogger(&EchoLogrusLogger{
Logger: logrus.StandardLogger(),
Ctx: c.Request().Context(),
})
ell := NewEchoLogrusLogger(logrus.StandardLogger(), c.Request().Context())
defer ell.Close()
c.SetLogger(ell)
return next(c)
}
}