Documentation
¶
Index ¶
- Variables
- func AddExtField(field string, value interface{}) optparams.Option[Options]
- func AddHooks(hooks ...logrus.Hook) optparams.Option[Options]
- func Debug(message string, fields ...map[string]interface{})
- func Error(message string, fields ...map[string]interface{})
- func Fatal(message string, fields ...map[string]interface{})
- func GetLogger() *logrus.Logger
- func Info(message string, fields ...map[string]interface{})
- func New() *logrus.Logger
- func Panic(message string, fields ...map[string]interface{})
- func Set(opts ...optparams.Option[Options])
- func Trace(message string, fields ...map[string]interface{})
- func Warn(message string, fields ...map[string]interface{})
- func WithAddExtFields(extFields map[string]interface{}) optparams.Option[Options]
- func WithDefaultFieldMap(fm logrus.FieldMap) optparams.Option[Options]
- func WithDisableTimeField() optparams.Option[Options]
- func WithExtFields(extFields map[string]interface{}) optparams.Option[Options]
- func WithLevel(loglevel string) optparams.Option[Options]
- func WithOutput(writer io.Writer) optparams.Option[Options]
- func WithTextFormat() optparams.Option[Options]
- func WithTimeFormat(TimeFormat string) optparams.Option[Options]
- type Dict
- type FormatType
- type Log
- func (lg *Log) Debug(message string, fields ...map[string]interface{})
- func (lg *Log) Error(message string, fields ...map[string]interface{})
- func (lg *Log) Fatal(message string, fields ...map[string]interface{})
- func (lg *Log) GetLogger() *logrus.Entry
- func (lg *Log) Info(message string, fields ...map[string]interface{})
- func (lg *Log) Panic(message string, fields ...map[string]interface{})
- func (lg *Log) Trace(message string, fields ...map[string]interface{})
- func (lg *Log) Warn(message string, fields ...map[string]interface{})
- type Options
Constants ¶
This section is empty.
Variables ¶
var DefaultOpts = Options{ Type: FormatType_JSON, TimeFormat: time.RFC3339Nano, Level: logrus.DebugLevel, DefaultFieldMap: logrus.FieldMap{ logrus.FieldKeyTime: "time", logrus.FieldKeyLevel: "level", logrus.FieldKeyMsg: "event", logrus.FieldKeyLogrusError: "logrus_error", logrus.FieldKeyFunc: "caller", logrus.FieldKeyFile: "file", }, ExtFields: map[string]interface{}{}, Hooks: []logrus.Hook{}, }
Functions ¶
func AddExtField ¶
AddExtField SetLogger函数的参数,用于增加扩展字段
func Debug ¶
Debug 默认log打印Debug级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func Error ¶
Error 默认log打印Error级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func Fatal ¶
Fatal 默认log打印Fatal级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func Info ¶
Info 默认log打印Info级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func Panic ¶
Panic 默认log打印Panic级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func Trace ¶
Trace 默认log打印Trace级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func Warn ¶
Warn 默认log打印Warn级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func WithAddExtFields ¶
WithAddExtFields SetLogger函数的参数,用于添加设置扩展字段
func WithDefaultFieldMap ¶
WithDefaultFieldMap SetLogger函数的参数,用于设置默认字段的新命名
func WithDisableTimeField ¶
WithDisableTimeField SetLogger函数的参数,用于设置使用text格式替换json格式
func WithExtFields ¶
WithExtFields SetLogger函数的参数,用于重置扩展字段
func WithOutput ¶
WithOutput SetLogger函数的参数,用于设置log的写入io
func WithTextFormat ¶
WithTextFormat SetLogger函数的参数,用于设置使用text格式替换json格式
Types ¶
type FormatType ¶
type FormatType int32
redis类型
const ( FormatType_JSON FormatType = 0 FormatType_Text FormatType = 1 )
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
针对不同业务可以设置不同的Log对象 它是固定了一些字段的logger
func (*Log) Debug ¶
Debug 打印Debug级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func (*Log) Error ¶
Error 打印Error级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func (*Log) Fatal ¶
Fatal 打印Fatal级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func (*Log) Info ¶
Info 打印Info级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
func (*Log) Panic ¶
Panic 打印Panic级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
type Options ¶
type Options struct { Type FormatType DisableTimeField bool TimeFormat string Level logrus.Level DefaultFieldMap logrus.FieldMap ExtFields map[string]interface{} Output io.Writer Hooks []logrus.Hook }
Option 设置key行为的选项 @attribute MaxTTL time.Duration 为0则不设置过期 @attribute AutoRefresh string 需要为crontab格式的字符串,否则不会自动定时刷新