Documentation ¶
Index ¶
- Constants
- func Debug(message string, args ...interface{})
- func DoInit()
- func Error(message string, args ...interface{})
- func Fatal(message string, args ...interface{})
- func Flush() error
- func GetCustomLog(k string, v interface{}) *logrus.Entry
- func GetLogger() *logrus.Logger
- func Info(message string, args ...interface{})
- func InitLogger(option *Option)
- func Panic(message string, args ...interface{})
- func SetLogLevel(level string)
- func StderrFatalf(message string, args ...interface{})
- func Warn(message string, args ...interface{})
- func Writer() io.Writer
- type AsyncRotaLog
- type DefaultFormatter
- type DefaultHook
- type Level
- type Option
Constants ¶
View Source
const ( FileNameDateFormat = "%Y%m%d" TimestampFormat = "2006-01-02 15:04:05.000" Text = "text" JSON = "json" DataKey = "data" Func = "func" )
Variables ¶
This section is empty.
Functions ¶
func GetCustomLog ¶
GetCustomLog return log entry with context set by custom k,v. note: no need release
func InitLogger ¶
func InitLogger(option *Option)
func SetLogLevel ¶
func SetLogLevel(level string)
SetLogLevel set log level, we need when server hot-reload for debug
func StderrFatalf ¶
func StderrFatalf(message string, args ...interface{})
Types ¶
type AsyncRotaLog ¶
type AsyncRotaLog struct {
// contains filtered or unexported fields
}
func NewRotaLogWriter ¶
func NewRotaLogWriter(o *Option) *AsyncRotaLog
func (*AsyncRotaLog) Close ¶
func (al *AsyncRotaLog) Close() error
type DefaultFormatter ¶
type DefaultFormatter struct { TextFormatter *logrus.TextFormatter FmtTpl string FileInfoField string Color bool }
type DefaultHook ¶
type DefaultHook struct { }
func (*DefaultHook) Levels ¶
func (h *DefaultHook) Levels() []logrus.Level
type Option ¶
type Option struct { // log目录 LogFolder string // log文件名 LogFile string // 日志类型 json|text LogType string // 文件名的日期格式 FileNameDateFormat string // 日志中日期时间格式 TimestampFormat string // 日志级别 LogLevel string // 是否打印到控制台 Log2Console bool // 是否异步刷新 Async bool // 日志最长保存多久 MaxAge time.Duration // 日志默认多长时间轮转一次 RotationTime time.Duration // 是否开启记录文件名和行号 IsEnableRecordFileInfo bool // 文件名和行号字段名 FileInfoField string // json日志是否美化输出 JSONPrettyPrint bool // json日志条目中 数据字段都会作为该字段的嵌入字段 JSONDataKey string // Text模式下日志打印的格式字符串,两个占位符:caller、message内容 TextFmtTpl string }
func DefaultOption ¶
func DefaultOption() *Option
Click to show internal directories.
Click to hide internal directories.