Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(a ...interface{})
- func Debugf(format string, a ...interface{})
- func Error(a ...interface{})
- func Errorf(format string, a ...interface{})
- func Fatal(a ...interface{})
- func Fatalf(format string, a ...interface{})
- func Info(a ...interface{})
- func Infof(format string, a ...interface{})
- func MustNewFormatter(format, timeLayout string) *formatter
- func MustNewHandlerToFile(lvl Lvl, formatter *formatter, logfile string, doTrunc bool) *handler
- func NewFormatter(format, timeLayout string) (*formatter, error)
- func NewHandlerToFile(lvl Lvl, formatter *formatter, logfile string, doTrunc bool) (*handler, error)
- func NewHandlerToRotateLogs(lvl Lvl, formatter *formatter, r *rotatelogs.RotateLogs) *handler
- func NewHandlerToWriter(lvl Lvl, formatter *formatter, w io.Writer, disableColor bool) *handler
- func SetGlobalHandlers(handlers ...*handler)
- func SetGlobalToGeneric(stdLvl, fileLvl Lvl)
- func SetGlobalToSimple()
- func Warning(a ...interface{})
- func Warningf(format string, a ...interface{})
- type Lvl
- type MixLog
- func (m *MixLog) Debug(a ...interface{})
- func (m *MixLog) Debugf(format string, a ...interface{})
- func (m *MixLog) Error(a ...interface{})
- func (m *MixLog) Errorf(format string, a ...interface{})
- func (m *MixLog) Fatal(a ...interface{})
- func (m *MixLog) Fatalf(format string, a ...interface{})
- func (m *MixLog) Info(a ...interface{})
- func (m *MixLog) Infof(format string, a ...interface{})
- func (m *MixLog) SetHandler(handlers ...*handler)
- func (m *MixLog) Warning(a ...interface{})
- func (m *MixLog) Warningf(format string, a ...interface{})
Constants ¶
View Source
const ( // 日志条目格式化成字符串的常用模板 FormatLongFileName = "{{.Lvl}} - {{.Time}} - {{.LongFileName}}({{.Line}}) - {{.Message}}" FormatShortFileName = "{{.Lvl}} - {{.Time}} - {{.ShortFilename}}({{.Line}}) - {{.Message}}" FormatFuncNameLongFileName = "{{.Lvl}} - {{.Time}} - {{.FuncName}} - {{.LongFileName}}({{.Line}}) - {{.Message}}" FormatFuncNameShortFileName = "{{.Lvl}} - {{.Time}} - {{.FuncName}} - {{.ShortFilename}}({{.Line}}) - {{.Message}}" )
Variables ¶
View Source
var LvlColorMap = map[Lvl]*color.Color{ LvlDebug: color.New(color.FgWhite), LvlInfo: color.New(color.FgCyan), LvlWarning: color.New(color.FgYellow), LvlError: color.New(color.FgHiRed), LvlFatal: color.New(color.FgMagenta), }
LvlColorMap 等级和颜色的映射
Functions ¶
func MustNewFormatter ¶
func MustNewFormatter(format, timeLayout string) *formatter
func MustNewHandlerToFile ¶
MustNewHandlerToFile 创建一个 handler,日志写入到指定的文件
func NewFormatter ¶
NewFormatter 创建一个格式化器
func NewHandlerToFile ¶
func NewHandlerToFile(lvl Lvl, formatter *formatter, logfile string, doTrunc bool) (*handler, error)
NewHandlerToFile 创建一个 handler,日志写入到指定的文件
func NewHandlerToRotateLogs ¶
func NewHandlerToRotateLogs(lvl Lvl, formatter *formatter, r *rotatelogs.RotateLogs) *handler
NewHandlerToRotateLogs 创建一个 handler,日志写入到 `*rotatelogs.RotateLogs` rotatelogs 是一个的滚动日志包,地址:https://github.com/lestrrat-go/file-rotatelogs
func NewHandlerToWriter ¶
NewHandlerToWriter 创建一个 handler,日志写入到 io.Writer
func SetGlobalToGeneric ¶
func SetGlobalToGeneric(stdLvl, fileLvl Lvl)
SetGlobalToGeneric 将全局对象设置为通用模式
Types ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.