Skip to content

Commit

Permalink
Improve acme logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored and traefiker committed Jul 22, 2019
1 parent 75c99a0 commit 2850098
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/provider/acme/challenge_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (p *Provider) Append(router *mux.Router) {
Handler(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)

ctx := log.With(context.Background(), log.Str(log.ProviderName, "acme"))
ctx := log.With(context.Background(), log.Str(log.ProviderName, p.ResolverName+".acme"))
logger := log.FromContext(ctx)

if token, ok := vars["token"]; ok {
Expand Down
13 changes: 6 additions & 7 deletions pkg/provider/acme/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ func (p *Provider) ListenConfiguration(config dynamic.Configuration) {

// Init for compatibility reason the BaseProvider implements an empty Init
func (p *Provider) Init() error {

ctx := log.With(context.Background(), log.Str(log.ProviderName, "acme"))
ctx := log.With(context.Background(), log.Str(log.ProviderName, p.ResolverName+".acme"))
logger := log.FromContext(ctx)

if len(p.Configuration.Storage) == 0 {
Expand Down Expand Up @@ -167,7 +166,7 @@ func isAccountMatchingCaServer(ctx context.Context, accountURI string, serverURI
// Provide allows the file provider to provide configurations to traefik
// using the given Configuration channel.
func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error {
ctx := log.With(context.Background(), log.Str(log.ProviderName, "acme."+p.ResolverName))
ctx := log.With(context.Background(), log.Str(log.ProviderName, p.ResolverName+".acme"))

p.pool = pool

Expand Down Expand Up @@ -199,7 +198,7 @@ func (p *Provider) getClient() (*lego.Client, error) {
p.clientMutex.Lock()
defer p.clientMutex.Unlock()

ctx := log.With(context.Background(), log.Str(log.ProviderName, "acme"))
ctx := log.With(context.Background(), log.Str(log.ProviderName, p.ResolverName+".acme"))
logger := log.FromContext(ctx)

if p.client != nil {
Expand Down Expand Up @@ -371,7 +370,7 @@ func (p *Provider) watchNewDomains(ctx context.Context) {
domain := domains[i]
safe.Go(func() {
if _, err := p.resolveCertificate(ctx, domain, tlsStore); err != nil {
log.WithoutContext().WithField(log.ProviderName, "acme."+p.ResolverName).
log.WithoutContext().WithField(log.ProviderName, p.ResolverName+".acme").
Errorf("Unable to obtain ACME certificate for domains %q : %v", strings.Join(domain.ToStrArray(), ","), err)
}
})
Expand Down Expand Up @@ -400,7 +399,7 @@ func (p *Provider) watchNewDomains(ctx context.Context) {
domain := domains[i]
safe.Go(func() {
if _, err := p.resolveCertificate(ctx, domain, tlsStore); err != nil {
log.WithoutContext().WithField(log.ProviderName, "acme."+p.ResolverName).
log.WithoutContext().WithField(log.ProviderName, p.ResolverName+".acme").
Errorf("Unable to obtain ACME certificate for domains %q : %v", strings.Join(domain.ToStrArray(), ","), err)
}
})
Expand Down Expand Up @@ -593,7 +592,7 @@ func (p *Provider) saveCertificates() error {

func (p *Provider) refreshCertificates() {
conf := dynamic.Message{
ProviderName: "acme." + p.ResolverName,
ProviderName: p.ResolverName + ".acme",
Configuration: &dynamic.Configuration{
HTTP: &dynamic.HTTPConfiguration{
Routers: map[string]*dynamic.Router{},
Expand Down

0 comments on commit 2850098

Please sign in to comment.