Use logrus writer instead of os.Stderr
This commit is contained in:
parent
bb3f28ffa7
commit
5b2b29043c
11 changed files with 16 additions and 4 deletions
|
@ -9,7 +9,6 @@ import (
|
||||||
fmtlog "log"
|
fmtlog "log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -27,6 +26,7 @@ import (
|
||||||
"github.com/containous/traefik/types"
|
"github.com/containous/traefik/types"
|
||||||
"github.com/containous/traefik/version"
|
"github.com/containous/traefik/version"
|
||||||
"github.com/eapache/channels"
|
"github.com/eapache/channels"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/xenolf/lego/acme"
|
"github.com/xenolf/lego/acme"
|
||||||
legolog "github.com/xenolf/lego/log"
|
legolog "github.com/xenolf/lego/log"
|
||||||
"github.com/xenolf/lego/providers/dns"
|
"github.com/xenolf/lego/providers/dns"
|
||||||
|
@ -65,16 +65,19 @@ type ACME struct {
|
||||||
|
|
||||||
func (a *ACME) init() error {
|
func (a *ACME) init() error {
|
||||||
acme.UserAgent = fmt.Sprintf("containous-traefik/%s", version.Version)
|
acme.UserAgent = fmt.Sprintf("containous-traefik/%s", version.Version)
|
||||||
|
|
||||||
if a.ACMELogging {
|
if a.ACMELogging {
|
||||||
legolog.Logger = fmtlog.New(os.Stderr, "legolog: ", fmtlog.LstdFlags)
|
legolog.Logger = fmtlog.New(log.WriterLevel(logrus.DebugLevel), "legolog: ", 0)
|
||||||
} else {
|
} else {
|
||||||
legolog.Logger = fmtlog.New(ioutil.Discard, "", 0)
|
legolog.Logger = fmtlog.New(ioutil.Discard, "", 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// no certificates in TLS config, so we add a default one
|
// no certificates in TLS config, so we add a default one
|
||||||
cert, err := generate.DefaultCertificate()
|
cert, err := generate.DefaultCertificate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
a.defaultCertificate = cert
|
a.defaultCertificate = cert
|
||||||
|
|
||||||
a.jobs = channels.NewInfiniteChannel()
|
a.jobs = channels.NewInfiniteChannel()
|
||||||
|
|
|
@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
|
||||||
email = "test@traefik.io"
|
email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.json"
|
storage = "/tmp/acme.json"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
|
acmeLogging = true
|
||||||
onDemand = {{.OnDemand}}
|
onDemand = {{.OnDemand}}
|
||||||
onHostRule = {{.OnHostRule}}
|
onHostRule = {{.OnHostRule}}
|
||||||
caServer = "http://{{.BoulderHost}}:4001/directory"
|
caServer = "http://{{.BoulderHost}}:4001/directory"
|
||||||
|
|
|
@ -13,6 +13,7 @@ defaultEntryPoints = ["http", "https"]
|
||||||
email = "test@traefik.io"
|
email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.json"
|
storage = "/tmp/acme.json"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
|
acmeLogging = true
|
||||||
onDemand = {{.OnDemand}}
|
onDemand = {{.OnDemand}}
|
||||||
onHostRule = {{.OnHostRule}}
|
onHostRule = {{.OnHostRule}}
|
||||||
caServer = "http://{{.BoulderHost}}:4001/directory"
|
caServer = "http://{{.BoulderHost}}:4001/directory"
|
||||||
|
|
|
@ -16,6 +16,7 @@ defaultEntryPoints = ["http", "https"]
|
||||||
email = "test@traefik.io"
|
email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.json"
|
storage = "/tmp/acme.json"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
|
acmeLogging = true
|
||||||
onDemand = {{.OnDemand}}
|
onDemand = {{.OnDemand}}
|
||||||
onHostRule = {{.OnHostRule}}
|
onHostRule = {{.OnHostRule}}
|
||||||
caServer = "http://{{.BoulderHost}}:4001/directory"
|
caServer = "http://{{.BoulderHost}}:4001/directory"
|
||||||
|
|
|
@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
|
||||||
email = "test@traefik.io"
|
email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.json"
|
storage = "/tmp/acme.json"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
|
acmeLogging = true
|
||||||
onDemand = {{.OnDemand}}
|
onDemand = {{.OnDemand}}
|
||||||
onHostRule = {{.OnHostRule}}
|
onHostRule = {{.OnHostRule}}
|
||||||
caServer = "http://{{.BoulderHost}}:4001/directory"
|
caServer = "http://{{.BoulderHost}}:4001/directory"
|
||||||
|
|
|
@ -17,6 +17,7 @@ email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.json"
|
storage = "/tmp/acme.json"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
onHostRule = true
|
onHostRule = true
|
||||||
|
acmeLogging = true
|
||||||
caServer = "http://{{.BoulderHost}}:4001/directory"
|
caServer = "http://{{.BoulderHost}}:4001/directory"
|
||||||
# No challenge defined
|
# No challenge defined
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ defaultEntryPoints = ["http", "https"]
|
||||||
email = "test@traefik.io"
|
email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.json"
|
storage = "/tmp/acme.json"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
|
acmeLogging = true
|
||||||
onHostRule = true
|
onHostRule = true
|
||||||
caServer = "http://wrongurl:4001/directory"
|
caServer = "http://wrongurl:4001/directory"
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
|
||||||
email = "test@traefik.io"
|
email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.json"
|
storage = "/tmp/acme.json"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
|
acmeLogging = true
|
||||||
onDemand = {{.OnDemand}}
|
onDemand = {{.OnDemand}}
|
||||||
onHostRule = {{.OnHostRule}}
|
onHostRule = {{.OnHostRule}}
|
||||||
caServer = "http://{{.BoulderHost}}:4001/directory"
|
caServer = "http://{{.BoulderHost}}:4001/directory"
|
||||||
|
|
|
@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
|
||||||
email = "test@traefik.io"
|
email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.json"
|
storage = "/tmp/acme.json"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
|
acmeLogging = true
|
||||||
onDemand = false
|
onDemand = false
|
||||||
onHostRule = false
|
onHostRule = false
|
||||||
caServer = "http://{{.BoulderHost}}:4001/directory"
|
caServer = "http://{{.BoulderHost}}:4001/directory"
|
||||||
|
|
|
@ -14,6 +14,7 @@ defaultEntryPoints = ["http", "https"]
|
||||||
email = "test@traefik.io"
|
email = "test@traefik.io"
|
||||||
storage = "/tmp/acme.jsonl"
|
storage = "/tmp/acme.jsonl"
|
||||||
entryPoint = "https"
|
entryPoint = "https"
|
||||||
|
acmeLogging = true
|
||||||
onDemand = {{.OnDemand}}
|
onDemand = {{.OnDemand}}
|
||||||
onHostRule = {{.OnHostRule}}
|
onHostRule = {{.OnHostRule}}
|
||||||
caServer = "http://{{.BoulderHost}}:4001/directory"
|
caServer = "http://{{.BoulderHost}}:4001/directory"
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
fmtlog "log"
|
fmtlog "log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -24,6 +23,7 @@ import (
|
||||||
"github.com/containous/traefik/types"
|
"github.com/containous/traefik/types"
|
||||||
"github.com/containous/traefik/version"
|
"github.com/containous/traefik/version"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/xenolf/lego/acme"
|
"github.com/xenolf/lego/acme"
|
||||||
legolog "github.com/xenolf/lego/log"
|
legolog "github.com/xenolf/lego/log"
|
||||||
"github.com/xenolf/lego/providers/dns"
|
"github.com/xenolf/lego/providers/dns"
|
||||||
|
@ -101,7 +101,7 @@ func (p *Provider) SetConfigListenerChan(configFromListenerChan chan types.Confi
|
||||||
func (p *Provider) init() error {
|
func (p *Provider) init() error {
|
||||||
acme.UserAgent = fmt.Sprintf("containous-traefik/%s", version.Version)
|
acme.UserAgent = fmt.Sprintf("containous-traefik/%s", version.Version)
|
||||||
if p.ACMELogging {
|
if p.ACMELogging {
|
||||||
legolog.Logger = fmtlog.New(os.Stderr, "legolog: ", fmtlog.LstdFlags)
|
legolog.Logger = fmtlog.New(log.WriterLevel(logrus.DebugLevel), "legolog: ", 0)
|
||||||
} else {
|
} else {
|
||||||
legolog.Logger = fmtlog.New(ioutil.Discard, "", 0)
|
legolog.Logger = fmtlog.New(ioutil.Discard, "", 0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue