Skip to content

Commit 1a1b288

Browse files
authored
Merge pull request #37 from fluxcd/json-logs
controllers: add JSON logging cmd flag
2 parents b69852e + eeab85c commit 1a1b288

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

config/manager/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ spec:
3131
args:
3232
- --enable-leader-election
3333
- --storage-path=/data
34+
- --log-json
3435
env:
3536
- name: RUNTIME_NAMESPACE
3637
valueFrom:

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func main() {
6363
storagePath string
6464
storageAddr string
6565
concurrent int
66+
logJSON bool
6667
)
6768

6869
flag.StringVar(&metricsAddr, "metrics-addr", ":9090", "The address the metric endpoint binds to.")
@@ -72,10 +73,11 @@ func main() {
7273
flag.StringVar(&storagePath, "storage-path", "", "The local storage path.")
7374
flag.StringVar(&storageAddr, "storage-addr", ":8080", "The address the static file server binds to.")
7475
flag.IntVar(&concurrent, "concurrent", 2, "The number of concurrent reconciles per controller.")
76+
flag.BoolVar(&logJSON, "log-json", false, "Set logging to JSON format.")
7577

7678
flag.Parse()
7779

78-
ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
80+
ctrl.SetLogger(zap.New(zap.UseDevMode(!logJSON)))
7981

8082
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
8183
Scheme: scheme,

0 commit comments

Comments
 (0)