Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(f interface{}, v ...interface{})
- func EnableColor(enable bool)
- func EnableFuncName(enable bool)
- func EnablePrefix(enable bool)
- func Error(f interface{}, v ...interface{})
- func Info(f interface{}, v ...interface{})
- func Panic(f interface{}, v ...interface{})
- func SetFlag(flag int)
- func SetMinLevel(minLevel Level)
- func Trace(f interface{}, v ...interface{})
- func Warn(f interface{}, v ...interface{})
- type Level
- type Logger
- func (p *Logger) Debug(f interface{}, v ...interface{})
- func (p *Logger) Error(f interface{}, v ...interface{})
- func (p *Logger) Info(f interface{}, v ...interface{})
- func (p *Logger) Panic(f interface{}, v ...interface{})
- func (p *Logger) Trace(f interface{}, v ...interface{})
- func (p *Logger) Warn(f interface{}, v ...interface{})
Constants ¶
View Source
const ( LevelTrace = iota LevelDebug LevelInfo LevelWarn LevelError LevelFatal )
Variables ¶
View Source
var LevelMap = map[string]int{ "FATA": LevelFatal, "ERRO": LevelError, "WARN": LevelWarn, "INFO": LevelInfo, "DEBU": LevelDebug, "TRAC": LevelTrace, }
日志等级和描述映射关系
View Source
var StrLevelMap = map[Level]string{ LevelFatal: "FATA", LevelError: "ERRO", LevelWarn: "WARN", LevelInfo: "INFO", LevelDebug: "DEBU", LevelTrace: "TRAC", }
Functions ¶
func SetMinLevel ¶
func SetMinLevel(minLevel Level)
SetMinLevel 设置最低日志级别,低于该级别的将不会打印 level值参考 LevelDebug
Types ¶
type Logger ¶
type Logger struct { Color bool `json:"color"` // 是否开启字体颜色 Prefix bool `json:"prefix"` // 是否开启前缀,比如[INFO] Func bool `json:"func"` // 是否显示函数名 Flag int `json:"flag"` // 属性,参考log.LstdFlags MinLevel Level `json:"min_level"` // 最低日志级别,参考Level类型 CallDepth int `json:"call_depth"` // 调用函数深度,特意提供可支持外部修改 }
Click to show internal directories.
Click to hide internal directories.