Documentation
¶
Index ¶
- Variables
- func CheckError(err error, fields ...zap.Field)
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func NewLogger(level, levelByStacktrace zapcore.LevelEnabler, writes ...zapcore.WriteSyncer) *zap.Logger
- func OpenPPROF(addr string)
- func Panic(msg string, fields ...zap.Field)
- func Print(args ...interface{})
- func Printf(format string, args ...interface{})
- func Sync()
- func Warn(msg string, fields ...zap.Field)
- func WrapObjToErr(obj interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultAtomicLevel zap.AtomicLevel
View Source
var DefaultLogger *zap.Logger
View Source
var Notify = func(callbacks ...func()) { notifyObjChan := make(chan os.Signal, 1) signal.Notify(notifyObjChan, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGHUP) forByNotify: for { s := <-notifyObjChan Info("notify", zap.Any("notifyObj", s)) switch s { case syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM: break forByNotify case syscall.SIGHUP: default: break forByNotify } } for _, callback := range callbacks { callback() } }
View Source
var Recover = func(showStack bool, defers ...func(recoverObj interface{})) { if recoverObj := recover(); recoverObj != nil { _, ok := recoverObj.(*panicByCheckError) if ok == false { if showStack { DefaultLogger.WithOptions(zap.AddCallerSkip(1)).Error("recover", zap.Any("recoverObj", recoverObj), zap.Stack("callStack")) } else { DefaultLogger.WithOptions(zap.AddCallerSkip(1)).Error("recover", zap.Any("recoverObj", recoverObj)) } } for _, v := range defers { v(recoverObj) } } }
Functions ¶
func CheckError ¶
func NewLogger ¶
func NewLogger(level, levelByStacktrace zapcore.LevelEnabler, writes ...zapcore.WriteSyncer) *zap.Logger
func WrapObjToErr ¶
func WrapObjToErr(obj interface{}) error
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.