Skip to content

Commit

Permalink
NO-JIRA: Add static.Logger() so new code can use non-static patterns.
Browse files Browse the repository at this point in the history
Add static.Logger() so that the static logger can be passed as an
argument. Allows old code using the static log pattern to be extended
with new code using log argument passing.
  • Loading branch information
xperimental authored and alanconway committed Jul 4, 2022
1 parent 5c5e884 commit bd76f47
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions log/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ func SetLogger(replacement logr.Logger) {
logger = replacement
}

// Logger returns the static logger instance.
func Logger() logr.Logger {
lock.RLock()
defer lock.RUnlock()
return logger
}

// WithName returns a logger with name added to the component.
// This uses the static logger instance.
func WithName(name string) logr.Logger {
Expand Down

0 comments on commit bd76f47

Please sign in to comment.