New logger for the Traefik logs
This commit is contained in:
parent
27c02b5a56
commit
56f7515ecd
297 changed files with 2337 additions and 1934 deletions
|
@ -9,8 +9,9 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
||||
"github.com/traefik/traefik/v2/pkg/log"
|
||||
"github.com/traefik/traefik/v2/pkg/logs"
|
||||
"github.com/traefik/traefik/v2/pkg/provider"
|
||||
"github.com/traefik/traefik/v2/pkg/safe"
|
||||
"github.com/traefik/yaegi/interp"
|
||||
|
@ -158,21 +159,21 @@ func (p *Provider) Init() error {
|
|||
func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.WithoutContext().WithField(log.ProviderName, p.name).Errorf("panic inside the plugin %v", err)
|
||||
log.Error().Str(logs.ProviderName, p.name).Msgf("Panic inside the plugin %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
cfgChan := make(chan json.Marshaler)
|
||||
|
||||
pool.GoCtx(func(ctx context.Context) {
|
||||
logger := log.FromContext(log.With(ctx, log.Str(log.ProviderName, p.name)))
|
||||
logger := log.Ctx(ctx).With().Str(logs.ProviderName, p.name).Logger()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err := p.pp.Stop()
|
||||
if err != nil {
|
||||
logger.Errorf("failed to stop the provider: %v", err)
|
||||
logger.Error().Err(err).Msg("Failed to stop the provider")
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -180,14 +181,14 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
|
|||
case cfgPg := <-cfgChan:
|
||||
marshalJSON, err := cfgPg.MarshalJSON()
|
||||
if err != nil {
|
||||
logger.Errorf("failed to marshal configuration: %v", err)
|
||||
logger.Error().Err(err).Msg("Failed to marshal configuration")
|
||||
continue
|
||||
}
|
||||
|
||||
cfg := &dynamic.Configuration{}
|
||||
err = json.Unmarshal(marshalJSON, cfg)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to unmarshal configuration: %v", err)
|
||||
logger.Error().Err(err).Msg("Failed to unmarshal configuration")
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue