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

Function NewStdLogAt

global.go:86–93  ·  view source on GitHub ↗

NewStdLogAt returns *log.Logger which writes to supplied zap logger at required level.

(l *Logger, level zapcore.Level)

Source from the content-addressed store, hash-verified

84// NewStdLogAt returns *log.Logger which writes to supplied zap logger at
85// required level.
86func NewStdLogAt(l *Logger, level zapcore.Level) (*log.Logger, error) {
87 logger := l.WithOptions(AddCallerSkip(_stdLogDefaultDepth + _loggerWriterDepth))
88 logFunc, err := levelToFunc(logger, level)
89 if err != nil {
90 return nil, err
91 }
92 return log.New(&loggerWriter{logFunc}, "" /* prefix */, 0 /* flags */), nil
93}
94
95// RedirectStdLog redirects output from the standard library's package-global
96// logger to the supplied logger at InfoLevel. Since zap already handles caller

Callers 4

TestNewStdLogAtFunction · 0.85
TestNewStdLogAtPanicsFunction · 0.85
TestNewStdLogAtFatalFunction · 0.85
TestNewStdLogAtInvalidFunction · 0.85

Calls 3

AddCallerSkipFunction · 0.85
levelToFuncFunction · 0.85
WithOptionsMethod · 0.45

Tested by 4

TestNewStdLogAtFunction · 0.68
TestNewStdLogAtPanicsFunction · 0.68
TestNewStdLogAtFatalFunction · 0.68
TestNewStdLogAtInvalidFunction · 0.68