Skip to content

Commit

Permalink
Merge pull request #6190 from sbueringer/pr-set-correct-klog-format
Browse files Browse the repository at this point in the history
🌱 logging: set correct klog format
  • Loading branch information
k8s-ci-robot authored Feb 24, 2022
2 parents ad276cb + 3d920cb commit 73ff976
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
13 changes: 5 additions & 8 deletions bootstrap/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,11 @@ func main() {
os.Exit(1)
}

// The JSON log format requires the Klog format in klog, otherwise log lines
// are serialized twice, e.g.:
// { ... "msg":"controller/cluster \"msg\"=\"Starting workers\"\n"}
if logOptions.Config.Format == logs.JSONLogFormat {
ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))
} else {
ctrl.SetLogger(klogr.New())
}
// Set the Klog format, as the Serialize format shouldn't be used anymore.
// This makes sure that the logs are formatted correctly, i.e.:
// * JSON logging format: msg isn't serialized twice
// * text logging format: values are formatted with their .String() func.
ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
Expand Down
13 changes: 5 additions & 8 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,11 @@ func main() {
os.Exit(1)
}

// The JSON log format requires the Klog format in klog, otherwise log lines
// are serialized twice, e.g.:
// { ... "msg":"controller/cluster \"msg\"=\"Starting workers\"\n"}
if logOptions.Config.Format == logs.JSONLogFormat {
ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))
} else {
ctrl.SetLogger(klogr.New())
}
// Set the Klog format, as the Serialize format shouldn't be used anymore.
// This makes sure that the logs are formatted correctly, i.e.:
// * JSON logging format: msg isn't serialized twice
// * text logging format: values are formatted with their .String() func.
ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
Expand Down
13 changes: 5 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,11 @@ func main() {
os.Exit(1)
}

// The JSON log format requires the Klog format in klog, otherwise log lines
// are serialized twice, e.g.:
// { ... "msg":"controller/cluster \"msg\"=\"Starting workers\"\n"}
if logOptions.Config.Format == logs.JSONLogFormat {
ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))
} else {
ctrl.SetLogger(klogr.New())
}
// Set the Klog format, as the Serialize format shouldn't be used anymore.
// This makes sure that the logs are formatted correctly, i.e.:
// * JSON logging format: msg isn't serialized twice
// * text logging format: values are formatted with their .String() func.
ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
Expand Down
13 changes: 5 additions & 8 deletions test/infrastructure/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,11 @@ func main() {
os.Exit(1)
}

// The JSON log format requires the Klog format in klog, otherwise log lines
// are serialized twice, e.g.:
// { ... "msg":"controller/cluster \"msg\"=\"Starting workers\"\n"}
if logOptions.Config.Format == logs.JSONLogFormat {
ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))
} else {
ctrl.SetLogger(klogr.New())
}
// Set the Klog format, as the Serialize format shouldn't be used anymore.
// This makes sure that the logs are formatted correctly, i.e.:
// * JSON logging format: msg isn't serialized twice
// * text logging format: values are formatted with their .String() func.
ctrl.SetLogger(klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)))

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
Expand Down

0 comments on commit 73ff976

Please sign in to comment.