Documentation ¶
Index ¶
- Variables
- 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 Info(message string, fields ...map[string]interface{})
- func Init(opts ...Option)
- func New() *logrus.Logger
- func Panic(message string, fields ...map[string]interface{})
- func Trace(message string, fields ...map[string]interface{})
- func Warn(message string, fields ...map[string]interface{})
- type Dict
- type FormatType
- type Option
- func AddExtField(field string, value interface{}) Option
- func AddHooks(hooks ...logrus.Hook) Option
- func WithDefaultFieldMap(fm logrus.FieldMap) Option
- func WithDisableTimeField() Option
- func WithExtFields(extFields map[string]interface{}) Option
- func WithLevel(loglevel string) Option
- func WithOutput(writer io.Writer) Option
- func WithTextFormat() Option
- func WithTimeFormat(TimeFormat string) Option
- 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{}, }
var Logger = New()
Logger 默认的logger
Functions ¶
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 Init ¶
func Init(opts ...Option)
Init 初始化默认的log对象 @params opts ...Option 初始化使用的参数,具体可以看options.go文件
func Panic ¶
Panic 默认log打印Panic级别信息 @params message string 事件消息 @params fields ...map[string]interface{} 信息字段
Types ¶
type FormatType ¶ added in v0.0.4
type FormatType int32
redis类型
const ( FormatType_JSON FormatType = 0 FormatType_Text FormatType = 1 )
type Option ¶ added in v0.0.4
type Option interface {
Apply(*Options)
}
Option configures how we set up the connection.
func AddExtField ¶ added in v0.0.4
AddExtField Init函数的参数,用于增加扩展字段
func WithDefaultFieldMap ¶ added in v0.0.4
WithDefaultFieldMap Init函数的参数,用于设置默认字段的新命名
func WithDisableTimeField ¶ added in v0.0.4
func WithDisableTimeField() Option
WithDisableTimeField Init函数的参数,用于设置使用text格式替换json格式
func WithExtFields ¶ added in v0.0.4
WithExtFields Init函数的参数,用于设置扩展字段
func WithOutput ¶ added in v0.0.4
WithOutput Init函数的参数,用于设置log的写入io
func WithTextFormat ¶ added in v0.0.4
func WithTextFormat() Option
WithTextFormat Init函数的参数,用于设置使用text格式替换json格式
func WithTimeFormat ¶ added in v0.0.4
WithTimeFormat Init函数的参数,用于设置使用指定的时间解析格式,默认为RFC3339Nano
type Options ¶ added in v0.0.4
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格式的字符串,否则不会自动定时刷新