From c4c45f8e01bd59b556eaa84f4d6c6ec529e01acb Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 29 Oct 2019 11:58:29 -0600 Subject: [PATCH] logging: Tweak defaults (enable logging by default, color level enc.) --- caddy.go | 11 ++++++----- logging.go | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/caddy.go b/caddy.go index dd241ee4..33e62968 100644 --- a/caddy.go +++ b/caddy.go @@ -119,11 +119,12 @@ func run(newCfg *Config, start bool) error { newCfg.cancelFunc = cancel // clean up later // set up logging before anything bad happens - if newCfg.Logging != nil { - err := newCfg.Logging.openLogs(ctx) - if err != nil { - return err - } + if newCfg.Logging == nil { + newCfg.Logging = new(Logging) + } + err = newCfg.Logging.openLogs(ctx) + if err != nil { + return err } // set up global storage and make it CertMagic's default storage, too diff --git a/logging.go b/logging.go index a70a7ea6..c29a0fa2 100644 --- a/logging.go +++ b/logging.go @@ -577,6 +577,7 @@ func newDefaultProductionLog() (*defaultCustomLog, error) { return nil, err } encCfg := zap.NewProductionEncoderConfig() + encCfg.EncodeLevel = zapcore.CapitalColorLevelEncoder cl.encoder = zapcore.NewConsoleEncoder(encCfg) cl.levelEnabler = zapcore.InfoLevel