Skip to content

Commit

Permalink
Manager should use the global logger, reduce log names verbosity (#1648)
Browse files Browse the repository at this point in the history
Currently a controller using the default logger has very verbose names
such as "controller-runtime/manager/controller/<name>", this changeset
reduces the verbosity of each log line to mostly have controller/<name>.

Signed-off-by: Stefan Büringer [email protected]
  • Loading branch information
sbueringer authored Aug 27, 2021
1 parent 91fcfd1 commit 2d2f85f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/log/deleg.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (p *loggerPromise) V(l *DelegatingLogger, level int) *loggerPromise {

// Fulfill instantiates the Logger with the provided logger.
func (p *loggerPromise) Fulfill(parentLogger logr.Logger) {
var logger = parentLogger
logger := logr.WithCallDepth(parentLogger, 1)
if p.name != nil {
logger = logger.WithName(*p.name)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/config"
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/healthz"
logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
intrec "sigs.k8s.io/controller-runtime/pkg/internal/recorder"
"sigs.k8s.io/controller-runtime/pkg/leaderelection"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/metrics"
"sigs.k8s.io/controller-runtime/pkg/recorder"
"sigs.k8s.io/controller-runtime/pkg/runtime/inject"
Expand Down Expand Up @@ -572,7 +572,7 @@ func setOptionsDefaults(options Options) Options {
}

if options.Logger == nil {
options.Logger = logf.RuntimeLog.WithName("manager")
options.Logger = log.Log
}

return options
Expand Down
4 changes: 2 additions & 2 deletions pkg/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/cluster"
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
logf "sigs.k8s.io/controller-runtime/pkg/internal/log"
intrec "sigs.k8s.io/controller-runtime/pkg/internal/recorder"
"sigs.k8s.io/controller-runtime/pkg/leaderelection"
fakeleaderelection "sigs.k8s.io/controller-runtime/pkg/leaderelection/fake"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/metrics"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/recorder"
Expand Down Expand Up @@ -1444,7 +1444,7 @@ var _ = Describe("manger.Manager", func() {
},
log: func(logger logr.Logger) error {
defer GinkgoRecover()
Expect(logger).To(Equal(logf.RuntimeLog.WithName("manager")))
Expect(logger).To(Equal(log.Log))
return nil
},
})
Expand Down

0 comments on commit 2d2f85f

Please sign in to comment.