From a65a04c1bdb26184a3e0b8a5a2fedb40f91b24af Mon Sep 17 00:00:00 2001 From: Yatin Karel Date: Tue, 13 Dec 2022 06:03:54 +0000 Subject: [PATCH] Logging: Use ISO8601 timestamps The default value for the zap logger is using epoch timestamps, but that's not user friendly, so we are changing it to using the ISO8601 time format instead. The zap package from uber is already a dependency from the zap module of the controller-runtime package we already use, so we are not adding any new dependency. Signed-off-by: Yatin Karel --- go.mod | 2 +- go.sum | 4 ++-- main.go | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b0fa146e..a424c5dd 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/openstack-k8s-operators/neutron-operator/api v0.0.0-00010101000000-000000000000 github.com/openstack-k8s-operators/openstack-operator/apis v0.0.0-20221117151703-eff71d81bcb7 github.com/openstack-k8s-operators/ovn-operator/api v0.0.0-20221123083203-3d9b7a0455a2 + go.uber.org/zap v1.22.0 k8s.io/api v0.25.5 k8s.io/apimachinery v0.26.0 k8s.io/client-go v0.25.5 @@ -66,7 +67,6 @@ require ( github.com/spf13/pflag v1.0.5 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect - go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.1.0 // indirect golang.org/x/net v0.4.0 // indirect golang.org/x/oauth2 v0.2.0 // indirect diff --git a/go.sum b/go.sum index 058ddfff..3ac75c10 100644 --- a/go.sum +++ b/go.sum @@ -349,8 +349,8 @@ go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9i go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.22.0 h1:Zcye5DUgBloQ9BaT4qc9BnjOFog5TvBSAGkJ3Nf70c0= +go.uber.org/zap v1.22.0/go.mod h1:H4siCOZOrAolnUPJEkfaSjDqyP+BDS0DdDWzwcgt3+U= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= diff --git a/main.go b/main.go index 2ec6e6c4..512306ac 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" routev1 "github.com/openshift/api/route/v1" + "go.uber.org/zap/zapcore" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -73,6 +74,7 @@ func main() { "Enabling this will ensure there is only one active controller manager.") opts := zap.Options{ Development: true, + TimeEncoder: zapcore.ISO8601TimeEncoder, } opts.BindFlags(flag.CommandLine) flag.Parse()