Skip to content

Commit

Permalink
make SetLogger thread-safe
Browse files Browse the repository at this point in the history
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
  • Loading branch information
mars1024 committed Apr 8, 2021
1 parent 3734278 commit e95c7e3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions klog.go
Expand Up @@ -861,6 +861,9 @@ func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) {
// ...
// klog.SetLogger(zapr.NewLogger(zapLog))
func SetLogger(logr logr.Logger) {
logging.mu.Lock()
defer logging.mu.Unlock()

logging.logr = logr
}

Expand Down

0 comments on commit e95c7e3

Please sign in to comment.