chore: updated logger injector middleware

This commit is contained in:
abelith committed 2026-10-06 13:46:20 +03:00
1 parent 185f859ee3
commit 6af79d8cda
1 file changed
+3 -2
+3 -2
View File
@@ -5,6 +5,7 @@ import (
mcontext "github.com/abelith/gomax/v1/context" mcontext "github.com/abelith/gomax/v1/context"
"github.com/abelith/gomax/v1/core" "github.com/abelith/gomax/v1/core"
merrors "github.com/abelith/gomax/v1/errors" merrors "github.com/abelith/gomax/v1/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )
@@ -40,10 +41,10 @@ func MwErrorResponder(defaultMsg string) core.Middleware {
} }
} }
func MwLoggerInjector() core.Middleware { func MwLoggerInjector(logger zerolog.Logger) core.Middleware {
return func(next core.HandlerFunc) core.HandlerFunc { return func(next core.HandlerFunc) core.HandlerFunc {
return func(c *mcontext.Context) error { return func(c *mcontext.Context) error {
ctx := log.Logger.With().Int64("user_id", c.Update().UserID). ctx := logger.With().Int64("user_id", c.Update().UserID).
Logger().WithContext(c.Context()) Logger().WithContext(c.Context())
c.SetContext(ctx) c.SetContext(ctx)
return next(c) return next(c)