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

Function redirectStdLogAt

global.go:123–139  ·  view source on GitHub ↗
(l *Logger, level zapcore.Level)

Source from the content-addressed store, hash-verified

121}
122
123func redirectStdLogAt(l *Logger, level zapcore.Level) (func(), error) {
124 flags := log.Flags()
125 prefix := log.Prefix()
126 log.SetFlags(0)
127 log.SetPrefix("")
128 logger := l.WithOptions(AddCallerSkip(_stdLogDefaultDepth + _loggerWriterDepth))
129 logFunc, err := levelToFunc(logger, level)
130 if err != nil {
131 return nil, err
132 }
133 log.SetOutput(&loggerWriter{logFunc})
134 return func() {
135 log.SetFlags(flags)
136 log.SetPrefix(prefix)
137 log.SetOutput(os.Stderr)
138 }, nil
139}
140
141func levelToFunc(logger *Logger, lvl zapcore.Level) (func(string, ...Field), error) {
142 switch lvl {

Callers 2

RedirectStdLogFunction · 0.85
RedirectStdLogAtFunction · 0.85

Calls 3

AddCallerSkipFunction · 0.85
levelToFuncFunction · 0.85
WithOptionsMethod · 0.45

Tested by

no test coverage detected