Documentation ¶
Index ¶
Constants ¶
View Source
const ( DEBUG = "DEBUG" INFO = "INFO" WARN = "WARN" ERROR = "ERROR" )
日志级别,配置文件定义的常量
View Source
const ( DEFAULT_MAX_AGE = 365 // 日志最长保存时间,单位:天 DEFAULT_ROTATION_TIME = 6 // 日志滚动间隔,单位:小时 )
日志切割默认配置
View Source
const ( ColorBlack color = iota + 30 ColorRed ColorGreen ColorYellow ColorBlue ColorMagenta ColorCyan ColorWhite )
Variables ¶
This section is empty.
Functions ¶
func CustomLevelEncoder ¶
func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
func CustomTimeEncoder ¶
func CustomTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
func InitSugarLogger ¶
func InitSugarLogger(logConfig *LogConfig) (*zap.SugaredLogger, zap.AtomicLevel)
Types ¶
type LogConfig ¶
type LogConfig struct { Module string // module: module name ChainId string // chainId: chain id LogPath string // logPath: log file save path LogLevel LOG_LEVEL // logLevel: log level MaxAge int // maxAge: the maximum number of days to retain old log files RotationTime int // RotationTime: rotation time JsonFormat bool // jsonFormat: log file use json format ShowLine bool // showLine: show filename and line number LogInConsole bool // logInConsole: show logs in console at the same time ShowColor bool // if true, show color log }
type LoggerInterface ¶
type LoggerInterface interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) }
Click to show internal directories.
Click to hide internal directories.