Skip to content

Commit

Permalink
⚠ Zap log: Default to RFC3339 time encoding
Browse files Browse the repository at this point in the history
The zap logger currently defaults to epoch time encoding which is pretty
much imposisble to parse for humands. Default to RFC339 instead, as that
is well-parseable by both humans and machines.
  • Loading branch information
alvaroaleman committed Oct 21, 2022
1 parent 9f9e840 commit 23f2a89
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/log/zap/zap.go
Expand Up @@ -217,7 +217,7 @@ func (o *Options) addDefaults() {
}

if o.TimeEncoder == nil {
o.TimeEncoder = zapcore.EpochTimeEncoder
o.TimeEncoder = zapcore.RFC3339TimeEncoder
}
f := func(ecfg *zapcore.EncoderConfig) {
ecfg.EncodeTime = o.TimeEncoder
Expand Down
4 changes: 2 additions & 2 deletions pkg/log/zap/zap_test.go
Expand Up @@ -502,7 +502,7 @@ var _ = Describe("Zap log level flag options setup", func() {
Expect(optVal.Pointer()).To(Equal(expVal.Pointer()))
})

It("Should default to 'epoch' time encoding", func() {
It("Should default to 'rfc3339' time encoding", func() {
args := []string{""}
fromFlags.BindFlags(&fs)
err := fs.Parse(args)
Expand All @@ -513,7 +513,7 @@ var _ = Describe("Zap log level flag options setup", func() {
opt.addDefaults()

optVal := reflect.ValueOf(opt.TimeEncoder)
expVal := reflect.ValueOf(zapcore.EpochTimeEncoder)
expVal := reflect.ValueOf(zapcore.RFC3339TimeEncoder)

Expect(optVal.Pointer()).To(Equal(expVal.Pointer()))
})
Expand Down

0 comments on commit 23f2a89

Please sign in to comment.