log messages in mixed format
When we display the log of the group-sync-operator the time format is mixed. Can we change the date/time format for all messages to a more readable version? xMMDD HH:MI:SS.ssssss
1.6921816787539868e+09 INFO controller-runtime.metrics Metrics server is starting to listen {"addr": "127.0.0.1:8080"}
1.6921816787543995e+09 INFO setup starting manager
1.6921816787546647e+09 INFO Starting server {"path": "/metrics", "kind": "metrics", "addr": "127.0.0.1:8080"}
1.6921816787547314e+09 INFO Starting server {"kind": "health probe", "addr": "[::]:8081"}
I0816 10:27:58.754788 1 leaderelection.go:248] attempting to acquire leader lease group-sync-operator/085c249a.redhat.io...
I0816 10:28:53.566548 1 leaderelection.go:258] successfully acquired lease group-sync-operator/085c249a.redhat.io
1.6921817335676498e+09 INFO Starting EventSource {"controller": "groupsync", "controllerGroup": "redhatcop.redhat.io", "controllerKind": "GroupSync", "source": "kind source: *v1alpha1.GroupSync"}
1.6921817335677052e+09 INFO Starting Controller {"controller": "groupsync", "controllerGroup": "redhatcop.redhat.io", "controllerKind": "GroupSync"}
1.6921817335685656e+09 DEBUG events Normal {"object": {"kind":"Lease","namespace":"group-sync-operator","name":"085c249a.redhat.io","uid":"8ed7b6ef-1f8d-420c-92c0-8277b263df58","apiVersion":"coordination.k8s.io/v1","resourceVersion":"1893983661"}, "reason": "LeaderElection", "message": "group-sync-operator-controller-manager-56f4c64d7-4zg64_0e577929-8a16-4c30-b1c5-a371ec183c1b became leader"}
any taker?
At the very least the code should call klog.SetLogger here so that the client-go logs go are in the same format as the rest of the logs.
This would fix those leaderelection.go entries.
But...that wouldn't fix the timestamps...
The simplest fix could be...
zapLogger := zap.New(zap.UseDevMode(true), func(config *zap.Options) {
config.TimeEncoder = zapcore.ISO8601TimeEncoder
})
klog.SetLogger(zapLogger)
ctrl.SetLogger(zapLogger)
It could also use the BindFlags mechanism which would allow configuration of the zap logger from the command-line...
This is what the namespace configuration operator does
You could then modify the deployment to allow additional options...
For example...adding --zap-devel --zap-time-encoding iso8601 would get you the same as the current settings but with ISO formatted timestamps (the same as the Go code above).
There's almost certainly some value in standardising this across operators...