Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion injection/sharedmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"knative.dev/pkg/injection"
"knative.dev/pkg/leaderelection"
"knative.dev/pkg/logging"
"knative.dev/pkg/logging/logkey"
"knative.dev/pkg/metrics"
"knative.dev/pkg/profiling"
"knative.dev/pkg/reconciler"
Expand Down Expand Up @@ -339,7 +340,16 @@ func SetupLoggerOrDie(ctx context.Context, component string) (*zap.SugaredLogger
if err != nil {
log.Fatalf("Error reading/parsing logging configuration: %v", err)
}
return logging.NewLoggerFromConfig(loggingConfig, component)
l, level := logging.NewLoggerFromConfig(loggingConfig, component)

// If PodName is injected into the env vars, set it on the logger.
// This is needed for HA components to distinguish logs from different
// pods.
if pn := os.Getenv("POD_NAME"); pn != "" {
l = l.With(zap.String(logkey.Pod, pn))
}

return l, level
}

// CheckK8sClientMinimumVersionOrDie checks that the hosting Kubernetes cluster
Expand Down