Skip to content

Commit ea46cdd

Browse files
committed
Configure logging with timestamps
Signed-off-by: ccremer <github.account@chrigel.net>
1 parent e28ba43 commit ea46cdd

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

cmd/k8up/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99

1010
"github.com/go-logr/logr"
1111
"github.com/urfave/cli/v2"
12+
"go.uber.org/zap"
1213
"go.uber.org/zap/zapcore"
13-
"sigs.k8s.io/controller-runtime/pkg/log/zap"
14+
controllerzap "sigs.k8s.io/controller-runtime/pkg/log/zap"
1415

1516
"github.com/k8up-io/k8up/v2/cmd"
1617
"github.com/k8up-io/k8up/v2/cmd/operator"
@@ -89,6 +90,9 @@ func newLogger(name string, debug bool) logr.Logger {
8990
if debug {
9091
level = zapcore.DebugLevel
9192
}
92-
logger := zap.New(zap.UseDevMode(true), zap.Level(level))
93+
cfg := zap.NewDevelopmentConfig()
94+
cfg.EncoderConfig.EncodeTime = zapcore.RFC3339TimeEncoder
95+
enc := zapcore.NewConsoleEncoder(cfg.EncoderConfig)
96+
logger := controllerzap.New(controllerzap.Level(level), controllerzap.Encoder(enc))
9397
return logger.WithName(name)
9498
}

operator/job/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (c *Config) SetStarted(message string, args ...interface{}) {
7373
if errors.IsNotFound(err) {
7474
return
7575
}
76-
c.Log.Error(err, "could not patch status")
76+
c.Log.Error(err, "could not update status")
7777
}
7878
}
7979

@@ -88,7 +88,7 @@ func (c *Config) SetFinished(namespace, name string) {
8888
if errors.IsNotFound(err) {
8989
return
9090
}
91-
c.Log.Error(err, "could not patch status")
91+
c.Log.Error(err, "could not update status")
9292
}
9393
}
9494

0 commit comments

Comments
 (0)