Skip to content

Commit

Permalink
Merge pull request #1204 from vincepri/controller-getlogger
Browse files Browse the repository at this point in the history
🌱 Add controller.GetLogger
  • Loading branch information
k8s-ci-robot committed Oct 2, 2020
2 parents e50bc83 + 885fa14 commit af2f5b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/controller/controller.go
Expand Up @@ -68,6 +68,9 @@ type Controller interface {
// Start starts the controller. Start blocks until the context is closed or a
// controller has an error starting.
Start(ctx context.Context) error

// GetLogger returns this controller logger prefilled with basic information.
GetLogger() logr.Logger
}

// New returns a new Controller registered with the Manager. The Manager will ensure that shared Caches have
Expand Down
5 changes: 5 additions & 0 deletions pkg/internal/controller/controller.go
Expand Up @@ -287,6 +287,11 @@ func (c *Controller) reconcileHandler(ctx context.Context, obj interface{}) {
ctrlmetrics.ReconcileTotal.WithLabelValues(c.Name, "success").Inc()
}

// GetLogger returns this controller's logger.
func (c *Controller) GetLogger() logr.Logger {
return c.Log
}

// InjectFunc implement SetFields.Injector
func (c *Controller) InjectFunc(f inject.Func) error {
c.SetFields = f
Expand Down

0 comments on commit af2f5b1

Please sign in to comment.