github.com/yandex/pandora@v0.5.32/lib/testutil/util.go (about) 1 package testutil 2 3 import ( 4 "go.uber.org/zap" 5 "go.uber.org/zap/zapcore" 6 "go.uber.org/zap/zaptest/observer" 7 ) 8 9 func ReplaceGlobalLogger() *zap.Logger { 10 log := NewLogger() 11 zap.ReplaceGlobals(log) 12 zap.RedirectStdLog(log) 13 return log 14 } 15 16 func NewLogger() *zap.Logger { 17 conf := zap.NewDevelopmentConfig() 18 conf.OutputPaths = []string{"stdout"} 19 conf.Level.SetLevel(zapcore.ErrorLevel) 20 log, err := conf.Build(zap.AddCaller(), zap.AddStacktrace(zap.PanicLevel)) 21 if err != nil { 22 zap.L().Fatal("Logger build failed", zap.Error(err)) 23 } 24 return log 25 } 26 27 func NewNullLogger() *zap.Logger { 28 c, _ := observer.New(zap.InfoLevel) 29 return zap.New(c) 30 }