From eeab85c0cb5db329ca50379a6b02db76b8289c14 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Fri, 24 Apr 2020 10:05:32 +0300 Subject: [PATCH] controllers: add JSON logging cmd flag --- config/manager/deployment.yaml | 1 + main.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/manager/deployment.yaml b/config/manager/deployment.yaml index 425fca39..eeebc82c 100644 --- a/config/manager/deployment.yaml +++ b/config/manager/deployment.yaml @@ -31,6 +31,7 @@ spec: args: - --enable-leader-election - --storage-path=/data + - --log-json env: - name: RUNTIME_NAMESPACE valueFrom: diff --git a/main.go b/main.go index 00372d16..1eff9a91 100644 --- a/main.go +++ b/main.go @@ -63,6 +63,7 @@ func main() { storagePath string storageAddr string concurrent int + logJSON bool ) flag.StringVar(&metricsAddr, "metrics-addr", ":9090", "The address the metric endpoint binds to.") @@ -72,10 +73,11 @@ func main() { flag.StringVar(&storagePath, "storage-path", "", "The local storage path.") flag.StringVar(&storageAddr, "storage-addr", ":8080", "The address the static file server binds to.") flag.IntVar(&concurrent, "concurrent", 2, "The number of concurrent reconciles per controller.") + flag.BoolVar(&logJSON, "log-json", false, "Set logging to JSON format.") flag.Parse() - ctrl.SetLogger(zap.New(zap.UseDevMode(true))) + ctrl.SetLogger(zap.New(zap.UseDevMode(!logJSON))) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme,