summaryrefslogtreecommitdiff
path: root/logging.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:14:22 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:14:22 -0700
commitb1f41d0ff1ee3e227d1d6e40ff7e215a2280dba2 (patch)
tree54890c0455f6206b6a549a857bd74a61fe79a773 /logging.go
parent6011ce120a4b2df9314a800fc93a61f852b766c1 (diff)
logging: Default logger should use wall time with milliseconds
This format is easier for humans to read and is still very precise.
Diffstat (limited to 'logging.go')
-rw-r--r--logging.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/logging.go b/logging.go
index c29a0fa..e809617 100644
--- a/logging.go
+++ b/logging.go
@@ -337,7 +337,7 @@ func (cl *CustomLog) provision(ctx Context, logging *Logging) error {
cl.encoder = val.(zapcore.Encoder)
}
if cl.encoder == nil {
- cl.encoder = zapcore.NewConsoleEncoder(zap.NewProductionEncoderConfig())
+ cl.encoder = newDefaultProductionLogEncoder()
}
if cl.WriterRaw != nil {
@@ -576,9 +576,7 @@ func newDefaultProductionLog() (*defaultCustomLog, error) {
if err != nil {
return nil, err
}
- encCfg := zap.NewProductionEncoderConfig()
- encCfg.EncodeLevel = zapcore.CapitalColorLevelEncoder
- cl.encoder = zapcore.NewConsoleEncoder(encCfg)
+ cl.encoder = newDefaultProductionLogEncoder()
cl.levelEnabler = zapcore.InfoLevel
cl.buildCore()
@@ -589,6 +587,15 @@ func newDefaultProductionLog() (*defaultCustomLog, error) {
}, nil
}
+func newDefaultProductionLogEncoder() zapcore.Encoder {
+ encCfg := zap.NewProductionEncoderConfig()
+ encCfg.EncodeLevel = zapcore.CapitalColorLevelEncoder
+ encCfg.EncodeTime = func(ts time.Time, encoder zapcore.PrimitiveArrayEncoder) {
+ encoder.AppendString(ts.UTC().Format("2006/01/02 15:04:05.000"))
+ }
+ return zapcore.NewConsoleEncoder(encCfg)
+}
+
// Log returns the current default logger.
func Log() *zap.Logger {
defaultLoggerMu.RLock()