New logger for the Traefik logs
This commit is contained in:
parent
27c02b5a56
commit
56f7515ecd
297 changed files with 2337 additions and 1934 deletions
|
@ -7,7 +7,6 @@ import (
|
|||
|
||||
"github.com/opentracing/opentracing-go/ext"
|
||||
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
||||
"github.com/traefik/traefik/v2/pkg/log"
|
||||
"github.com/traefik/traefik/v2/pkg/middlewares"
|
||||
"github.com/traefik/traefik/v2/pkg/tracing"
|
||||
)
|
||||
|
@ -25,7 +24,7 @@ type addPrefix struct {
|
|||
|
||||
// New creates a new handler.
|
||||
func New(ctx context.Context, next http.Handler, config dynamic.AddPrefix, name string) (http.Handler, error) {
|
||||
log.FromContext(middlewares.GetLoggerCtx(ctx, name, typeName)).Debug("Creating middleware")
|
||||
middlewares.GetLogger(ctx, name, typeName).Debug().Msg("Creating middleware")
|
||||
var result *addPrefix
|
||||
|
||||
if len(config.Prefix) > 0 {
|
||||
|
@ -46,16 +45,16 @@ func (a *addPrefix) GetTracingInformation() (string, ext.SpanKindEnum) {
|
|||
}
|
||||
|
||||
func (a *addPrefix) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
logger := log.FromContext(middlewares.GetLoggerCtx(req.Context(), a.name, typeName))
|
||||
logger := middlewares.GetLogger(req.Context(), a.name, typeName)
|
||||
|
||||
oldURLPath := req.URL.Path
|
||||
req.URL.Path = ensureLeadingSlash(a.prefix + req.URL.Path)
|
||||
logger.Debugf("URL.Path is now %s (was %s).", req.URL.Path, oldURLPath)
|
||||
logger.Debug().Msgf("URL.Path is now %s (was %s).", req.URL.Path, oldURLPath)
|
||||
|
||||
if req.URL.RawPath != "" {
|
||||
oldURLRawPath := req.URL.RawPath
|
||||
req.URL.RawPath = ensureLeadingSlash(a.prefix + req.URL.RawPath)
|
||||
logger.Debugf("URL.RawPath is now %s (was %s).", req.URL.RawPath, oldURLRawPath)
|
||||
logger.Debug().Msgf("URL.RawPath is now %s (was %s).", req.URL.RawPath, oldURLRawPath)
|
||||
}
|
||||
req.RequestURI = req.URL.RequestURI()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue