New logger for the Traefik logs

This commit is contained in:
Ludovic Fernandez 2022-11-21 18:36:05 +01:00 committed by GitHub
parent 27c02b5a56
commit 56f7515ecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
297 changed files with 2337 additions and 1934 deletions

View file

@ -7,7 +7,7 @@ import (
"os"
"time"
"github.com/traefik/traefik/v2/pkg/log"
"github.com/rs/zerolog/log"
corev1 "k8s.io/api/core/v1"
kubeerror "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -252,7 +252,7 @@ func (c *clientWrapper) GetNamespaces(selector labels.Selector) ([]string, error
var namespaces []string
for _, namespace := range ns {
if !c.isWatchedNamespace(namespace.Name) {
log.WithoutContext().Warnf("Namespace %q is not within watched namespaces", selector, namespace)
log.Warn().Msgf("Namespace %q is not within %q watched namespaces", selector, namespace)
continue
}
namespaces = append(namespaces, namespace.Name)
@ -264,7 +264,7 @@ func (c *clientWrapper) GetHTTPRoutes(namespaces []string) ([]*v1alpha2.HTTPRout
var httpRoutes []*v1alpha2.HTTPRoute
for _, namespace := range namespaces {
if !c.isWatchedNamespace(namespace) {
log.WithoutContext().Warnf("Failed to get HTTPRoutes: %q is not within watched namespaces", namespace)
log.Warn().Msgf("Failed to get HTTPRoutes: %q is not within watched namespaces", namespace)
continue
}
@ -274,7 +274,7 @@ func (c *clientWrapper) GetHTTPRoutes(namespaces []string) ([]*v1alpha2.HTTPRout
}
if len(routes) == 0 {
log.WithoutContext().Debugf("No HTTPRoutes found in namespace %q", namespace)
log.Debug().Msgf("No HTTPRoutes found in namespace %q", namespace)
continue
}
@ -288,7 +288,7 @@ func (c *clientWrapper) GetTCPRoutes(namespaces []string) ([]*v1alpha2.TCPRoute,
var tcpRoutes []*v1alpha2.TCPRoute
for _, namespace := range namespaces {
if !c.isWatchedNamespace(namespace) {
log.WithoutContext().Warnf("Failed to get TCPRoutes: %q is not within watched namespaces", namespace)
log.Warn().Msgf("Failed to get TCPRoutes: %q is not within watched namespaces", namespace)
continue
}
@ -298,7 +298,7 @@ func (c *clientWrapper) GetTCPRoutes(namespaces []string) ([]*v1alpha2.TCPRoute,
}
if len(routes) == 0 {
log.WithoutContext().Debugf("No TCPRoutes found in namespace %q", namespace)
log.Debug().Msgf("No TCPRoutes found in namespace %q", namespace)
continue
}
@ -311,7 +311,7 @@ func (c *clientWrapper) GetTLSRoutes(namespaces []string) ([]*v1alpha2.TLSRoute,
var tlsRoutes []*v1alpha2.TLSRoute
for _, namespace := range namespaces {
if !c.isWatchedNamespace(namespace) {
log.WithoutContext().Warnf("Failed to get TLSRoutes: %q is not within watched namespaces", namespace)
log.Warn().Msgf("Failed to get TLSRoutes: %q is not within watched namespaces", namespace)
continue
}
@ -321,7 +321,7 @@ func (c *clientWrapper) GetTLSRoutes(namespaces []string) ([]*v1alpha2.TLSRoute,
}
if len(routes) == 0 {
log.WithoutContext().Debugf("No TLSRoutes found in namespace %q", namespace)
log.Debug().Msgf("No TLSRoutes found in namespace %q", namespace)
continue
}
@ -336,7 +336,7 @@ func (c *clientWrapper) GetGateways() []*v1alpha2.Gateway {
for ns, factory := range c.factoriesGateway {
gateways, err := factory.Gateway().V1alpha2().Gateways().Lister().List(labels.Everything())
if err != nil {
log.WithoutContext().Errorf("Failed to list Gateways in namespace %s: %v", ns, err)
log.Error().Err(err).Msgf("Failed to list Gateways in namespace %s", ns)
continue
}
result = append(result, gateways...)