Commit 3db78c9b authored by wei.xuan's avatar wei.xuan

logger

parent 2403c0eb
......@@ -38,24 +38,13 @@ type Logger interface {
type LoggerLevel int8
const (
// DebugLevel logs are typically voluminous, and are usually disabled in
// production.
LoggerLevelDebug = LoggerLevel(zapcore.DebugLevel)
// InfoLevel is the default logging priority.
LoggerLevelInfo = LoggerLevel(zapcore.InfoLevel)
// WarnLevel logs are more important than Infof, but don't need individual
// human review.
LoggerLevelWarn = LoggerLevel(zapcore.WarnLevel)
// ErrorLevel logs are high-priority. If an application is running smoothly,
// it shouldn't generate any error-level logs.
LoggerLevelError = LoggerLevel(zapcore.ErrorLevel)
// DPanicLevel logs are particularly important errors. In development the
// logger panics after writing the message.
LoggerLevelDebug = LoggerLevel(zapcore.DebugLevel)
LoggerLevelInfo = LoggerLevel(zapcore.InfoLevel)
LoggerLevelWarn = LoggerLevel(zapcore.WarnLevel)
LoggerLevelError = LoggerLevel(zapcore.ErrorLevel)
LoggerLevelDPanic = LoggerLevel(zapcore.DPanicLevel)
// PanicLevel logs a message, then panics.
LoggerLevelPanic = LoggerLevel(zapcore.PanicLevel)
// FatalLevel logs a message, then calls os.Exit(1).
LoggerLevelFatal = LoggerLevel(zapcore.FatalLevel)
LoggerLevelPanic = LoggerLevel(zapcore.PanicLevel)
LoggerLevelFatal = LoggerLevel(zapcore.FatalLevel)
)
var (
......@@ -81,20 +70,6 @@ func init() {
zapLoggerConfig.EncoderConfig = zapLoggerEncoderConfig
zapLogger, _ = zapLoggerConfig.Build()
log = zapLogger.Sugar()
// todo: flushes buffer when redirect log to file.
// var exitSignal = make(chan os.Signal)
// signal.Notify(exitSignal, syscall.SIGTERM, syscall.SIGINT)
// go func() {
// <-exitSignal
// // Sync calls the underlying Core's Sync method, flushing any buffered log
// // entries. Applications should take care to call Sync before exiting.
// err := zapLogger.Sync() // flushes buffer, if any
// if err != nil {
// fmt.Printf("zapLogger sync err: %+v", perrors.WithStack(err))
// }
// os.Exit(0)
// }()
}
// SetLogger customize yourself logger.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment