From b00dfd3965f400956c5bb5b388e9d54ef98052e5 Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Mon, 28 Oct 2019 14:39:37 -0600 Subject: v2: Logging! (#2831) * logging: Initial implementation * logging: More encoder formats, better defaults * logging: Fix repetition bug with FilterEncoder; add more presets * logging: DiscardWriter; delete or no-op logs that discard their output * logging: Add http.handlers.log module; enhance Replacer methods The Replacer interface has new methods to customize how to handle empty or unrecognized placeholders. Closes #2815. * logging: Overhaul HTTP logging, fix bugs, improve filtering, etc. * logging: General cleanup, begin transitioning to using new loggers * Fixes after merge conflict --- modules/caddytls/tls.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'modules/caddytls') diff --git a/modules/caddytls/tls.go b/modules/caddytls/tls.go index 5054081..5dfe063 100644 --- a/modules/caddytls/tls.go +++ b/modules/caddytls/tls.go @@ -18,7 +18,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - "log" "net/http" "sync" "time" @@ -26,6 +25,7 @@ import ( "github.com/caddyserver/caddy/v2" "github.com/go-acme/lego/v3/challenge" "github.com/mholt/certmagic" + "go.uber.org/zap" ) func init() { @@ -43,6 +43,7 @@ type TLS struct { ctx caddy.Context storageCleanTicker *time.Ticker storageCleanStop chan struct{} + logger *zap.Logger } // CaddyModule returns the Caddy module information. @@ -56,6 +57,7 @@ func (TLS) CaddyModule() caddy.ModuleInfo { // Provision sets up the configuration for the TLS app. func (t *TLS) Provision(ctx caddy.Context) error { t.ctx = ctx + t.logger = ctx.Logger(t) // set up a new certificate cache; this (re)loads all certificates cacheOpts := certmagic.CacheOptions{ @@ -290,7 +292,7 @@ func (t *TLS) cleanStorageUnits() { storageClean = time.Now() - log.Println("[INFO] tls: Cleaned up storage unit(s)") + t.logger.Info("cleaned up storage units") } // CertificateLoader is a type that can load certificates. -- cgit v1.2.3