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

@ -9,7 +9,8 @@ import (
"github.com/go-acme/lego/v4/certcrypto"
"github.com/go-acme/lego/v4/registration"
"github.com/traefik/traefik/v2/pkg/log"
"github.com/rs/zerolog/log"
"github.com/traefik/traefik/v2/pkg/logs"
)
// Account is used to store lets encrypt registration info.
@ -56,8 +57,8 @@ func (a *Account) GetRegistration() *registration.Resource {
func (a *Account) GetPrivateKey() crypto.PrivateKey {
privateKey, err := x509.ParsePKCS1PrivateKey(a.PrivateKey)
if err != nil {
log.WithoutContext().WithField(log.ProviderName, "acme").
Errorf("Cannot unmarshal private key %+v: %v", a.PrivateKey, err)
log.Error().Str(logs.ProviderName, "acme").
Err(err).Msgf("Cannot unmarshal private key %+v", a.PrivateKey)
return nil
}
@ -66,7 +67,7 @@ func (a *Account) GetPrivateKey() crypto.PrivateKey {
// GetKeyType used to determine which algo to used.
func GetKeyType(ctx context.Context, value string) certcrypto.KeyType {
logger := log.FromContext(ctx)
logger := log.Ctx(ctx)
switch value {
case "EC256":
@ -80,10 +81,10 @@ func GetKeyType(ctx context.Context, value string) certcrypto.KeyType {
case "RSA8192":
return certcrypto.RSA8192
case "":
logger.Infof("The key type is empty. Use default key type %v.", certcrypto.RSA4096)
logger.Info().Msgf("The key type is empty. Use default key type %v.", certcrypto.RSA4096)
return certcrypto.RSA4096
default:
logger.Infof("Unable to determine the key type value %q: falling back on %v.", value, certcrypto.RSA4096)
logger.Info().Msgf("Unable to determine the key type value %q: falling back on %v.", value, certcrypto.RSA4096)
return certcrypto.RSA4096
}
}