Move ACME logger setup to cmd/tlstunnel
This will allow us to customize the logger options depending on CLI flags.
This commit is contained in:
parent
55fdebc9b7
commit
4684feb935
|
@ -7,6 +7,7 @@ import (
|
|||
"git.sr.ht/~emersion/go-scfg"
|
||||
"git.sr.ht/~emersion/tlstunnel"
|
||||
"github.com/caddyserver/certmagic"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -25,6 +26,22 @@ func main() {
|
|||
|
||||
srv := tlstunnel.NewServer()
|
||||
|
||||
loggerCfg := zap.Config{
|
||||
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
|
||||
Encoding: "console",
|
||||
EncoderConfig: zap.NewDevelopmentEncoderConfig(),
|
||||
OutputPaths: []string{"stderr"},
|
||||
ErrorOutputPaths: []string{"stderr"},
|
||||
DisableStacktrace: true,
|
||||
DisableCaller: true,
|
||||
}
|
||||
logger, err := loggerCfg.Build()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to initialize zap logger: %v", err)
|
||||
}
|
||||
srv.ACMEConfig.Logger = logger
|
||||
srv.ACMEManager.Logger = logger
|
||||
|
||||
if certDataPath != "" {
|
||||
srv.ACMEConfig.Storage = &certmagic.FileStorage{Path: certDataPath}
|
||||
}
|
||||
|
|
17
server.go
17
server.go
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/caddyserver/certmagic"
|
||||
"github.com/pires/go-proxyproto"
|
||||
"github.com/pires/go-proxyproto/tlvparse"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
|
@ -37,22 +36,6 @@ func NewServer() *Server {
|
|||
cfg.Issuer = mgr
|
||||
cfg.Revoker = mgr
|
||||
|
||||
loggerCfg := zap.Config{
|
||||
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
|
||||
Encoding: "console",
|
||||
EncoderConfig: zap.NewDevelopmentEncoderConfig(),
|
||||
OutputPaths: []string{"stderr"},
|
||||
ErrorOutputPaths: []string{"stderr"},
|
||||
DisableStacktrace: true,
|
||||
DisableCaller: true,
|
||||
}
|
||||
logger, err := loggerCfg.Build()
|
||||
if err != nil {
|
||||
log.Fatalf("failed to initialize zap logger: %v", err)
|
||||
}
|
||||
cfg.Logger = logger
|
||||
mgr.Logger = logger
|
||||
|
||||
return &Server{
|
||||
Listeners: make(map[string]*Listener),
|
||||
ACMEManager: mgr,
|
||||
|
|
Loading…
Reference in New Issue