Skip to content

Commit

Permalink
Merge pull request #4620 from AndiDog/fix-logging
Browse files Browse the repository at this point in the history
Pass logger to machine pool scope to get verbosity right, fix copying logger in `With...` methods
  • Loading branch information
k8s-ci-robot committed Nov 28, 2023
2 parents 25f8108 + 70ada99 commit a1b6f35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions exp/controllers/awsmachinepool_controller.go
Expand Up @@ -131,6 +131,7 @@ func (r *AWSMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Reque
// Create the machine pool scope
machinePoolScope, err := scope.NewMachinePoolScope(scope.MachinePoolScopeParams{
Client: r.Client,
Logger: log,
Cluster: cluster,
MachinePool: machinePool,
InfraCluster: infraCluster,
Expand Down
12 changes: 8 additions & 4 deletions pkg/logger/logger.go
Expand Up @@ -99,11 +99,15 @@ func (c *Logger) GetLogger() logr.Logger {
}

func (c *Logger) WithValues(keysAndValues ...any) *Logger {
c.logger = c.logger.WithValues(keysAndValues...)
return c
return &Logger{
callStackHelper: c.callStackHelper,
logger: c.logger.WithValues(keysAndValues...),
}
}

func (c *Logger) WithName(name string) *Logger {
c.logger = c.logger.WithName(name)
return c
return &Logger{
callStackHelper: c.callStackHelper,
logger: c.logger.WithName(name),
}
}

0 comments on commit a1b6f35

Please sign in to comment.