MCPcopy
hub / github.com/uber-go/zap / ReplaceGlobals

Function ReplaceGlobals

global.go:66–73  ·  view source on GitHub ↗

ReplaceGlobals replaces the global Logger and SugaredLogger, and returns a function to restore the original values. It's safe for concurrent use.

(logger *Logger)

Source from the content-addressed store, hash-verified

64// ReplaceGlobals replaces the global Logger and SugaredLogger, and returns a
65// function to restore the original values. It's safe for concurrent use.
66func ReplaceGlobals(logger *Logger) func() {
67 _globalMu.Lock()
68 prev := _globalL
69 _globalL = logger
70 _globalS = logger.Sugar()
71 _globalMu.Unlock()
72 return func() { ReplaceGlobals(prev) }
73}
74
75// NewStdLog returns a *log.Logger which writes to the supplied zap Logger at
76// InfoLevel. To redirect the standard library's package-global logging

Callers 3

ExampleReplaceGlobalsFunction · 0.92
TestReplaceGlobalsFunction · 0.85
TestGlobalsConcurrentUseFunction · 0.85

Calls 1

SugarMethod · 0.80

Tested by 3

ExampleReplaceGlobalsFunction · 0.74
TestReplaceGlobalsFunction · 0.68
TestGlobalsConcurrentUseFunction · 0.68