Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logger): changed logger to ISO8601TimeEncoder #1626

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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