Skip to content

Commit

Permalink
Merge pull request #1626 from haarchri/feature/zap-logger-iso8601
Browse files Browse the repository at this point in the history
feat(logger): changed logger to ISO8601TimeEncoder
  • Loading branch information
Christopher Haar committed Jan 12, 2023
2 parents 38d1abc + bc6746c commit f86f4ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/logging"
"github.com/crossplane/crossplane-runtime/pkg/ratelimiter"
"github.com/crossplane/crossplane-runtime/pkg/resource"
"go.uber.org/zap/zapcore"

"github.com/crossplane-contrib/provider-aws/apis"
"github.com/crossplane-contrib/provider-aws/apis/v1alpha1"
Expand All @@ -56,7 +57,7 @@ func main() {
)
kingpin.MustParse(app.Parse(os.Args[1:]))

zl := zap.New(zap.UseDevMode(*debug))
zl := zap.New(zap.UseDevMode(*debug), UseISO8601())
log := logging.NewLogrLogger(zl.WithName("provider-aws"))
if *debug {
// The controller-runtime runs with a no-op logger by default. It is
Expand Down Expand Up @@ -120,3 +121,10 @@ func main() {
kingpin.FatalIfError(mgr.Start(ctrl.SetupSignalHandler()), "Cannot start controller manager")

}

// UseISO8601 sets the logger to use ISO8601 timestamp format
func UseISO8601() zap.Opts {
return func(o *zap.Options) {
o.TimeEncoder = zapcore.ISO8601TimeEncoder
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ require (
github.com/mitchellh/copystructure v1.0.0
github.com/onsi/gomega v1.17.0
github.com/pkg/errors v0.9.1
go.uber.org/zap v1.19.1
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
gopkg.in/alecthomas/kingpin.v2 v2.2.6
k8s.io/api v0.23.0
Expand Down Expand Up @@ -124,7 +125,6 @@ require (
github.com/stretchr/testify v1.8.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa // indirect
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
Expand Down

0 comments on commit f86f4ce

Please sign in to comment.