Skip to content

Commit

Permalink
Merge pull request #2029 from alvaroaleman/rfc339
Browse files Browse the repository at this point in the history
⚠ Zap log: Default to RFC3339 time encoding
  • Loading branch information
k8s-ci-robot committed Oct 22, 2022
2 parents 9f9e840 + 60e524b commit 090611b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/log/zap/zap.go
Expand Up @@ -168,7 +168,7 @@ type Options struct {
// underlying Zap logger.
ZapOpts []zap.Option
// TimeEncoder specifies the encoder for the timestamps in log messages.
// Defaults to EpochTimeEncoder as this is the default in Zap currently.
// Defaults to RFC3339TimeEncoder.
TimeEncoder zapcore.TimeEncoder
}

Expand Down 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 090611b

Please sign in to comment.