~emersion/tlstunnel

4684feb935a8ca58f4eb96afb29ef23fb6ccc1c6 — Simon Ser 6 months ago 55fdebc
Move ACME logger setup to cmd/tlstunnel

This will allow us to customize the logger options depending on CLI
flags.
2 files changed, 17 insertions(+), 17 deletions(-)

M cmd/tlstunnel/main.go
M server.go
M cmd/tlstunnel/main.go => cmd/tlstunnel/main.go +17 -0
@@ 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}
	}

M server.go => server.go +0 -17
@@ 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,