fix: logger and context.

This commit is contained in:
Ludovic Fernandez 2019-09-13 19:28:04 +02:00 committed by Traefiker Bot
parent b4c7b90c9e
commit 8e18d37b3d
52 changed files with 231 additions and 183 deletions

View file

@ -4,10 +4,9 @@ import (
"context"
"github.com/containous/traefik/v2/pkg/log"
"github.com/sirupsen/logrus"
)
// GetLogger creates a logger configured with the middleware fields.
func GetLogger(ctx context.Context, middleware string, middlewareType string) logrus.FieldLogger {
return log.FromContext(ctx).WithField(log.MiddlewareName, middleware).WithField(log.MiddlewareType, middlewareType)
// GetLoggerCtx creates a logger context with the middleware fields.
func GetLoggerCtx(ctx context.Context, middleware string, middlewareType string) context.Context {
return log.With(ctx, log.Str(log.MiddlewareName, middleware), log.Str(log.MiddlewareType, middlewareType))
}