chore: updated logger injector middleware
This commit is contained in:
1 parent
185f859ee3
commit
6af79d8cda
1 file changed
+3
-2
@@ -5,6 +5,7 @@ import (
|
||||
mcontext "github.com/abelith/gomax/v1/context"
|
||||
"github.com/abelith/gomax/v1/core"
|
||||
merrors "github.com/abelith/gomax/v1/errors"
|
||||
"github.com/rs/zerolog"
|
||||
"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(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())
|
||||
c.SetContext(ctx)
|
||||
return next(c)
|
||||
|
||||
Reference in new issue
Block a user