Skip to content

Commit

Permalink
Use logrus writer instead of os.Stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored and traefiker committed Jun 15, 2018
1 parent bb3f28f commit 5b2b290
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 4 deletions.
7 changes: 5 additions & 2 deletions acme/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
fmtlog "log"
"net"
"net/http"
"os"
"reflect"
"strings"
"time"
Expand All @@ -27,6 +26,7 @@ import (
"github.com/containous/traefik/types"
"github.com/containous/traefik/version"
"github.com/eapache/channels"
"github.com/sirupsen/logrus"
"github.com/xenolf/lego/acme"
legolog "github.com/xenolf/lego/log"
"github.com/xenolf/lego/providers/dns"
Expand Down Expand Up @@ -65,16 +65,19 @@ type ACME struct {

func (a *ACME) init() error {
acme.UserAgent = fmt.Sprintf("containous-traefik/%s", version.Version)

if a.ACMELogging {
legolog.Logger = fmtlog.New(os.Stderr, "legolog: ", fmtlog.LstdFlags)
legolog.Logger = fmtlog.New(log.WriterLevel(logrus.DebugLevel), "legolog: ", 0)
} else {
legolog.Logger = fmtlog.New(ioutil.Discard, "", 0)
}

// no certificates in TLS config, so we add a default one
cert, err := generate.DefaultCertificate()
if err != nil {
return err
}

a.defaultCertificate = cert

a.jobs = channels.NewInfiniteChannel()
Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/acme/acme_http01.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
email = "test@traefik.io"
storage = "/tmp/acme.json"
entryPoint = "https"
acmeLogging = true
onDemand = {{.OnDemand}}
onHostRule = {{.OnHostRule}}
caServer = "http://{{.BoulderHost}}:4001/directory"
Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/acme/acme_http01_web.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defaultEntryPoints = ["http", "https"]
email = "test@traefik.io"
storage = "/tmp/acme.json"
entryPoint = "https"
acmeLogging = true
onDemand = {{.OnDemand}}
onHostRule = {{.OnHostRule}}
caServer = "http://{{.BoulderHost}}:4001/directory"
Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/acme/acme_provided.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defaultEntryPoints = ["http", "https"]
email = "test@traefik.io"
storage = "/tmp/acme.json"
entryPoint = "https"
acmeLogging = true
onDemand = {{.OnDemand}}
onHostRule = {{.OnHostRule}}
caServer = "http://{{.BoulderHost}}:4001/directory"
Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/acme/acme_provided_dynamic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
email = "test@traefik.io"
storage = "/tmp/acme.json"
entryPoint = "https"
acmeLogging = true
onDemand = {{.OnDemand}}
onHostRule = {{.OnHostRule}}
caServer = "http://{{.BoulderHost}}:4001/directory"
Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/acme/no_challenge_acme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ email = "test@traefik.io"
storage = "/tmp/acme.json"
entryPoint = "https"
onHostRule = true
acmeLogging = true
caServer = "http://{{.BoulderHost}}:4001/directory"
# No challenge defined

Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/acme/wrong_acme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defaultEntryPoints = ["http", "https"]
email = "test@traefik.io"
storage = "/tmp/acme.json"
entryPoint = "https"
acmeLogging = true
onHostRule = true
caServer = "http://wrongurl:4001/directory"

Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/provideracme/acme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
email = "test@traefik.io"
storage = "/tmp/acme.json"
entryPoint = "https"
acmeLogging = true
onDemand = {{.OnDemand}}
onHostRule = {{.OnHostRule}}
caServer = "http://{{.BoulderHost}}:4001/directory"
Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/provideracme/acme_insan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
email = "test@traefik.io"
storage = "/tmp/acme.json"
entryPoint = "https"
acmeLogging = true
onDemand = false
onHostRule = false
caServer = "http://{{.BoulderHost}}:4001/directory"
Expand Down
1 change: 1 addition & 0 deletions integration/fixtures/provideracme/acme_onhost.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
email = "test@traefik.io"
storage = "/tmp/acme.jsonl"
entryPoint = "https"
acmeLogging = true
onDemand = {{.OnDemand}}
onHostRule = {{.OnHostRule}}
caServer = "http://{{.BoulderHost}}:4001/directory"
Expand Down
4 changes: 2 additions & 2 deletions provider/acme/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
fmtlog "log"
"net"
"net/http"
"os"
"reflect"
"strings"
"sync"
Expand All @@ -24,6 +23,7 @@ import (
"github.com/containous/traefik/types"
"github.com/containous/traefik/version"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/xenolf/lego/acme"
legolog "github.com/xenolf/lego/log"
"github.com/xenolf/lego/providers/dns"
Expand Down Expand Up @@ -101,7 +101,7 @@ func (p *Provider) SetConfigListenerChan(configFromListenerChan chan types.Confi
func (p *Provider) init() error {
acme.UserAgent = fmt.Sprintf("containous-traefik/%s", version.Version)
if p.ACMELogging {
legolog.Logger = fmtlog.New(os.Stderr, "legolog: ", fmtlog.LstdFlags)
legolog.Logger = fmtlog.New(log.WriterLevel(logrus.DebugLevel), "legolog: ", 0)
} else {
legolog.Logger = fmtlog.New(ioutil.Discard, "", 0)
}
Expand Down

0 comments on commit 5b2b290

Please sign in to comment.