New logger for the Traefik logs
This commit is contained in:
parent
27c02b5a56
commit
56f7515ecd
297 changed files with 2337 additions and 1934 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/hashicorp/go-version"
|
||||
"github.com/traefik/traefik/v2/pkg/log"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/traefik/traefik/v2/pkg/provider/kubernetes/k8s"
|
||||
traefikversion "github.com/traefik/traefik/v2/pkg/version"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
|
@ -246,7 +246,7 @@ func (c *clientWrapper) GetIngresses() []*networkingv1.Ingress {
|
|||
// networking
|
||||
listNew, err := factory.Networking().V1().Ingresses().Lister().List(labels.Everything())
|
||||
if err != nil {
|
||||
log.WithoutContext().Errorf("Failed to list ingresses in namespace %s: %v", ns, err)
|
||||
log.Error().Err(err).Msgf("Failed to list ingresses in namespace %s", ns)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -257,14 +257,14 @@ func (c *clientWrapper) GetIngresses() []*networkingv1.Ingress {
|
|||
// networking beta
|
||||
list, err := factory.Networking().V1beta1().Ingresses().Lister().List(labels.Everything())
|
||||
if err != nil {
|
||||
log.WithoutContext().Errorf("Failed to list ingresses in namespace %s: %v", ns, err)
|
||||
log.Error().Err(err).Msgf("Failed to list ingresses in namespace %s", ns)
|
||||
continue
|
||||
}
|
||||
|
||||
for _, ing := range list {
|
||||
n, err := toNetworkingV1(ing)
|
||||
if err != nil {
|
||||
log.WithoutContext().Errorf("Failed to convert ingress %s from networking/v1beta1 to networking/v1: %v", ns, err)
|
||||
log.Error().Err(err).Msgf("Failed to convert ingress %s from networking/v1beta1 to networking/v1", ns)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -366,10 +366,10 @@ func (c *clientWrapper) UpdateIngressStatus(src *networkingv1.Ingress, ingStatus
|
|||
return fmt.Errorf("failed to get ingress %s/%s: %w", src.Namespace, src.Name, err)
|
||||
}
|
||||
|
||||
logger := log.WithoutContext().WithField("namespace", ing.Namespace).WithField("ingress", ing.Name)
|
||||
logger := log.With().Str("namespace", ing.Namespace).Str("ingress", ing.Name).Logger()
|
||||
|
||||
if isLoadBalancerIngressEquals(ing.Status.LoadBalancer.Ingress, ingStatus) {
|
||||
logger.Debug("Skipping ingress status update")
|
||||
logger.Debug().Msg("Skipping ingress status update")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ func (c *clientWrapper) UpdateIngressStatus(src *networkingv1.Ingress, ingStatus
|
|||
return fmt.Errorf("failed to update ingress status %s/%s: %w", src.Namespace, src.Name, err)
|
||||
}
|
||||
|
||||
logger.Info("Updated ingress status")
|
||||
logger.Info().Msg("Updated ingress status")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -394,10 +394,10 @@ func (c *clientWrapper) updateIngressStatusOld(src *networkingv1.Ingress, ingSta
|
|||
return fmt.Errorf("failed to get ingress %s/%s: %w", src.Namespace, src.Name, err)
|
||||
}
|
||||
|
||||
logger := log.WithoutContext().WithField("namespace", ing.Namespace).WithField("ingress", ing.Name)
|
||||
logger := log.With().Str("namespace", ing.Namespace).Str("ingress", ing.Name).Logger()
|
||||
|
||||
if isLoadBalancerIngressEquals(ing.Status.LoadBalancer.Ingress, ingStatus) {
|
||||
logger.Debug("Skipping ingress status update")
|
||||
logger.Debug().Msg("Skipping ingress status update")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ func (c *clientWrapper) updateIngressStatusOld(src *networkingv1.Ingress, ingSta
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to update ingress status %s/%s: %w", src.Namespace, src.Name, err)
|
||||
}
|
||||
logger.Info("Updated ingress status")
|
||||
logger.Info().Msg("Updated ingress status")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ func (c *clientWrapper) GetIngressClasses() ([]*networkingv1.IngressClass, error
|
|||
if ic.Spec.Controller == traefikDefaultIngressClassController {
|
||||
icN, err := toNetworkingV1IngressClass(ic)
|
||||
if err != nil {
|
||||
log.WithoutContext().Errorf("Failed to convert ingress class %s from networking/v1beta1 to networking/v1: %v", ic.Name, err)
|
||||
log.Error().Err(err).Msgf("Failed to convert ingress class %s from networking/v1beta1 to networking/v1", ic.Name)
|
||||
continue
|
||||
}
|
||||
ics = append(ics, icN)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue