Documentation
¶
Overview ¶
logger 基于zap日志库,进行封装的logger库 支持日志自动切割
Index ¶
- func Compress(b bool)
- func DPanic(msg string, options map[string]interface{})
- func Debug(msg string, options map[string]interface{})
- func Error(msg string, options map[string]interface{})
- func Fatal(msg string, options map[string]interface{})
- func Info(msg string, options map[string]interface{})
- func InitLogger(skip ...int)
- func LogLevel(lvl string)
- func LogSugar(skip ...int) *zap.SugaredLogger
- func MaxAge(n int)
- func MaxSize(n int)
- func Panic(msg string, options map[string]interface{})
- func Recover()
- func SetLogDir(dir string)
- func SetLogFile(name string)
- func TraceFileLine(b bool)
- func Warn(msg string, options map[string]interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
func InitLogger(skip ...int)
* InitLogger 初始化fLogger句柄,skip指定显示文件名和行号的层级 skip 大于0会调用zap.AddCallerSkip Caller(skip int)函数可以返回当前goroutine调用栈中的文件名,行号,函数信息等 参数skip表示表示返回的栈帧的层次,0表示runtime.Caller的调用者,依次往上推导 而golang 标准库中runtime.Caller(2) 返回当前goroutine调用栈中的文件名,行号,函数信息 如果直接调用这个logger库中的Info,Error等方法,这里skip=1 如果基于logger进行日志再进行封装,这个skip=2,依次类推 zap底层源码从v1.14版本之后,logger.go#260 check func check must always be called directly by a method in the Logger interface (e.g., Check, Info, Fatal). const callerSkipOffset = 2 这里的callerSkipOffset默认是2,所以这里InitLogger skip需要初始化为1
func LogSugar ¶
func LogSugar(skip ...int) *zap.SugaredLogger
LogSugar sugar语法糖,支持简单的msg信息打印 支持Debug,Info,Error,Panic,Warn,Fatal等方法
Types ¶
This section is empty.