1
0
Fork 0

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

@ -6,8 +6,9 @@ import (
"time"
"github.com/go-acme/lego/v4/challenge/tlsalpn01"
"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/safe"
traefiktls "github.com/traefik/traefik/v2/pkg/tls"
"github.com/traefik/traefik/v2/pkg/types"
@ -36,8 +37,8 @@ func NewChallengeTLSALPN() *ChallengeTLSALPN {
// Present presents a challenge to obtain new ACME certificate.
func (c *ChallengeTLSALPN) Present(domain, _, keyAuth string) error {
logger := log.WithoutContext().WithField(log.ProviderName, providerNameALPN)
logger.Debugf("TLS Challenge Present temp certificate for %s", domain)
logger := log.With().Str(logs.ProviderName, providerNameALPN).Logger()
logger.Debug().Msgf("TLS Challenge Present temp certificate for %s", domain)
certPEMBlock, keyPEMBlock, err := tlsalpn01.ChallengeBlocks(domain, keyAuth)
if err != nil {
@ -71,7 +72,7 @@ func (c *ChallengeTLSALPN) Present(domain, _, keyAuth string) error {
err = c.CleanUp(domain, "", keyAuth)
if err != nil {
logger.Errorf("Failed to clean up TLS challenge: %v", err)
logger.Error().Err(err).Msg("Failed to clean up TLS challenge")
}
return fmt.Errorf("timeout %s", t)
@ -83,8 +84,8 @@ func (c *ChallengeTLSALPN) Present(domain, _, keyAuth string) error {
// CleanUp cleans the challenges when certificate is obtained.
func (c *ChallengeTLSALPN) CleanUp(domain, _, keyAuth string) error {
log.WithoutContext().WithField(log.ProviderName, providerNameALPN).
Debugf("TLS Challenge CleanUp temp certificate for %s", domain)
log.Debug().Str(logs.ProviderName, providerNameALPN).
Msgf("TLS Challenge CleanUp temp certificate for %s", domain)
c.muCerts.Lock()
delete(c.certs, keyAuth)