Documentation ¶
Index ¶
- func Debug(v ...interface{})
- func DebugWithContext(context *context.Context, v ...interface{})
- func Debugf(template string, v ...interface{})
- func DebugfWithContext(context *context.Context, template string, v ...interface{})
- func Error(v ...interface{})
- func ErrorWithContext(context *context.Context, v ...interface{})
- func Errorf(template string, v ...interface{})
- func ErrorfWithContext(context *context.Context, template string, v ...interface{})
- func Fatal(v ...interface{})
- func FatalWithContext(context *context.Context, v ...interface{})
- func Fatalf(template string, v ...interface{})
- func FatalfWithContext(context *context.Context, template string, v ...interface{})
- func Flush()
- func Info(v ...interface{})
- func InfoWithContext(context *context.Context, v ...interface{})
- func Infof(template string, v ...interface{})
- func InfofWithContext(context *context.Context, template string, v ...interface{})
- func InitLogger(properties *Properties)
- func IsDebugEnabled() bool
- func IsErrorEnabled() bool
- func IsFatalEnabled() bool
- func IsInfoEnabled() bool
- func IsWarnEnabled() bool
- func ResolveAndApplyDefaultProperties(properties *Properties)
- func SetAfterLogHandler(...)
- func SetRootLogger(logger Logger)
- func SetTraceIdGenerator(generator TraceIdGenerator)
- func Warn(v ...interface{})
- func WarnWithContext(context *context.Context, v ...interface{})
- func Warnf(template string, v ...interface{})
- func WarnfWithContext(context *context.Context, template string, v ...interface{})
- type ConsoleLogger
- func (c *ConsoleLogger) Debug(v ...interface{})
- func (c *ConsoleLogger) DebugWithContext(context *context.Context, v ...interface{})
- func (c *ConsoleLogger) Debugf(template string, v ...interface{})
- func (c *ConsoleLogger) DebugfWithContext(context *context.Context, template string, v ...interface{})
- func (c *ConsoleLogger) Error(v ...interface{})
- func (c *ConsoleLogger) ErrorWithContext(context *context.Context, v ...interface{})
- func (c *ConsoleLogger) Errorf(template string, v ...interface{})
- func (c *ConsoleLogger) ErrorfWithContext(context *context.Context, template string, v ...interface{})
- func (c *ConsoleLogger) Fatal(v ...interface{})
- func (c *ConsoleLogger) FatalWithContext(context *context.Context, v ...interface{})
- func (c *ConsoleLogger) Fatalf(template string, v ...interface{})
- func (c *ConsoleLogger) FatalfWithContext(context *context.Context, template string, v ...interface{})
- func (c *ConsoleLogger) Flush()
- func (c *ConsoleLogger) GetLevel() Level
- func (c *ConsoleLogger) Info(v ...interface{})
- func (c *ConsoleLogger) InfoWithContext(context *context.Context, v ...interface{})
- func (c *ConsoleLogger) Infof(template string, v ...interface{})
- func (c *ConsoleLogger) InfofWithContext(context *context.Context, template string, v ...interface{})
- func (c *ConsoleLogger) IsDebugEnabled() bool
- func (c *ConsoleLogger) IsErrorEnabled() bool
- func (c *ConsoleLogger) IsFatalEnabled() bool
- func (c *ConsoleLogger) IsInfoEnabled() bool
- func (c *ConsoleLogger) IsWarnEnabled() bool
- func (c *ConsoleLogger) Warn(v ...interface{})
- func (c *ConsoleLogger) WarnWithContext(context *context.Context, v ...interface{})
- func (c *ConsoleLogger) Warnf(template string, v ...interface{})
- func (c *ConsoleLogger) WarnfWithContext(context *context.Context, template string, v ...interface{})
- type Level
- type Logger
- type Properties
- type TraceIdGenerator
- type ZapLogger
- func (z *ZapLogger) Debug(v ...interface{})
- func (z *ZapLogger) DebugWithContext(context *context.Context, v ...interface{})
- func (z *ZapLogger) Debugf(template string, v ...interface{})
- func (z *ZapLogger) DebugfWithContext(context *context.Context, template string, v ...interface{})
- func (z *ZapLogger) Error(v ...interface{})
- func (z *ZapLogger) ErrorWithContext(context *context.Context, v ...interface{})
- func (z *ZapLogger) Errorf(template string, v ...interface{})
- func (z *ZapLogger) ErrorfWithContext(context *context.Context, template string, v ...interface{})
- func (z *ZapLogger) Fatal(v ...interface{})
- func (z *ZapLogger) FatalWithContext(context *context.Context, v ...interface{})
- func (z *ZapLogger) Fatalf(template string, v ...interface{})
- func (z *ZapLogger) FatalfWithContext(context *context.Context, template string, v ...interface{})
- func (z *ZapLogger) Flush()
- func (z *ZapLogger) GetLevel() Level
- func (z *ZapLogger) Info(v ...interface{})
- func (z *ZapLogger) InfoWithContext(context *context.Context, v ...interface{})
- func (z *ZapLogger) Infof(template string, v ...interface{})
- func (z *ZapLogger) InfofWithContext(context *context.Context, template string, v ...interface{})
- func (z *ZapLogger) IsDebugEnabled() bool
- func (z *ZapLogger) IsErrorEnabled() bool
- func (z *ZapLogger) IsFatalEnabled() bool
- func (z *ZapLogger) IsInfoEnabled() bool
- func (z *ZapLogger) IsWarnEnabled() bool
- func (z *ZapLogger) Warn(v ...interface{})
- func (z *ZapLogger) WarnWithContext(context *context.Context, v ...interface{})
- func (z *ZapLogger) Warnf(template string, v ...interface{})
- func (z *ZapLogger) WarnfWithContext(context *context.Context, template string, v ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugWithContext ¶
func DebugfWithContext ¶
func ErrorWithContext ¶
func ErrorfWithContext ¶
func FatalWithContext ¶
func FatalfWithContext ¶
func InfoWithContext ¶
func InfofWithContext ¶
func InitLogger ¶
func InitLogger(properties *Properties)
func IsDebugEnabled ¶
func IsDebugEnabled() bool
func IsErrorEnabled ¶
func IsErrorEnabled() bool
func IsFatalEnabled ¶
func IsFatalEnabled() bool
func IsInfoEnabled ¶
func IsInfoEnabled() bool
func IsWarnEnabled ¶
func IsWarnEnabled() bool
func ResolveAndApplyDefaultProperties ¶
func ResolveAndApplyDefaultProperties(properties *Properties)
* 处理默认配置信息
func SetAfterLogHandler ¶
func SetRootLogger ¶
func SetRootLogger(logger Logger)
func SetTraceIdGenerator ¶
func SetTraceIdGenerator(generator TraceIdGenerator)
func WarnWithContext ¶
func WarnfWithContext ¶
Types ¶
type ConsoleLogger ¶
type ConsoleLogger struct { Level Level // 日志级别 CallerSkipOffset int // 输出日志时候,计算输入日志的日志所在文件和行数偏移,一般给应用进行二次封装使用,正负数都可以 }
func (*ConsoleLogger) Debug ¶
func (c *ConsoleLogger) Debug(v ...interface{})
func (*ConsoleLogger) DebugWithContext ¶
func (c *ConsoleLogger) DebugWithContext(context *context.Context, v ...interface{})
func (*ConsoleLogger) Debugf ¶
func (c *ConsoleLogger) Debugf(template string, v ...interface{})
func (*ConsoleLogger) DebugfWithContext ¶
func (c *ConsoleLogger) DebugfWithContext(context *context.Context, template string, v ...interface{})
func (*ConsoleLogger) Error ¶
func (c *ConsoleLogger) Error(v ...interface{})
func (*ConsoleLogger) ErrorWithContext ¶
func (c *ConsoleLogger) ErrorWithContext(context *context.Context, v ...interface{})
func (*ConsoleLogger) Errorf ¶
func (c *ConsoleLogger) Errorf(template string, v ...interface{})
func (*ConsoleLogger) ErrorfWithContext ¶
func (c *ConsoleLogger) ErrorfWithContext(context *context.Context, template string, v ...interface{})
func (*ConsoleLogger) Fatal ¶
func (c *ConsoleLogger) Fatal(v ...interface{})
func (*ConsoleLogger) FatalWithContext ¶
func (c *ConsoleLogger) FatalWithContext(context *context.Context, v ...interface{})
func (*ConsoleLogger) Fatalf ¶
func (c *ConsoleLogger) Fatalf(template string, v ...interface{})
func (*ConsoleLogger) FatalfWithContext ¶
func (c *ConsoleLogger) FatalfWithContext(context *context.Context, template string, v ...interface{})
func (*ConsoleLogger) Flush ¶
func (c *ConsoleLogger) Flush()
func (*ConsoleLogger) GetLevel ¶
func (c *ConsoleLogger) GetLevel() Level
func (*ConsoleLogger) Info ¶
func (c *ConsoleLogger) Info(v ...interface{})
func (*ConsoleLogger) InfoWithContext ¶
func (c *ConsoleLogger) InfoWithContext(context *context.Context, v ...interface{})
func (*ConsoleLogger) Infof ¶
func (c *ConsoleLogger) Infof(template string, v ...interface{})
func (*ConsoleLogger) InfofWithContext ¶
func (c *ConsoleLogger) InfofWithContext(context *context.Context, template string, v ...interface{})
func (*ConsoleLogger) IsDebugEnabled ¶
func (c *ConsoleLogger) IsDebugEnabled() bool
func (*ConsoleLogger) IsErrorEnabled ¶
func (c *ConsoleLogger) IsErrorEnabled() bool
func (*ConsoleLogger) IsFatalEnabled ¶
func (c *ConsoleLogger) IsFatalEnabled() bool
func (*ConsoleLogger) IsInfoEnabled ¶
func (c *ConsoleLogger) IsInfoEnabled() bool
func (*ConsoleLogger) IsWarnEnabled ¶
func (c *ConsoleLogger) IsWarnEnabled() bool
func (*ConsoleLogger) Warn ¶
func (c *ConsoleLogger) Warn(v ...interface{})
func (*ConsoleLogger) WarnWithContext ¶
func (c *ConsoleLogger) WarnWithContext(context *context.Context, v ...interface{})
func (*ConsoleLogger) Warnf ¶
func (c *ConsoleLogger) Warnf(template string, v ...interface{})
func (*ConsoleLogger) WarnfWithContext ¶
func (c *ConsoleLogger) WarnfWithContext(context *context.Context, template string, v ...interface{})
type Logger ¶
type Logger interface { Flush() GetLevel() Level IsDebugEnabled() bool IsInfoEnabled() bool IsWarnEnabled() bool IsErrorEnabled() bool IsFatalEnabled() bool Debug(v ...interface{}) Debugf(template string, v ...interface{}) DebugWithContext(context *context.Context, v ...interface{}) DebugfWithContext(context *context.Context, template string, v ...interface{}) Info(v ...interface{}) Infof(template string, v ...interface{}) InfoWithContext(context *context.Context, v ...interface{}) InfofWithContext(context *context.Context, template string, v ...interface{}) Warn(v ...interface{}) Warnf(template string, v ...interface{}) WarnWithContext(context *context.Context, v ...interface{}) WarnfWithContext(context *context.Context, template string, v ...interface{}) Error(v ...interface{}) Errorf(template string, v ...interface{}) ErrorWithContext(context *context.Context, v ...interface{}) ErrorfWithContext(context *context.Context, template string, v ...interface{}) Fatal(v ...interface{}) Fatalf(template string, v ...interface{}) FatalWithContext(context *context.Context, v ...interface{}) FatalfWithContext(context *context.Context, template string, v ...interface{}) }
日志初始化
func RootLogger ¶
func RootLogger() *Logger
type Properties ¶
type Properties struct { Level string `ck:"level" def:"DEBUG"` // 日志级别: DEBUG, INFO, WARN, ERROR, FATAL, 默认是: DEBUG Dir string `ck:"dir" def:"./logs"` // 日志存放目录, 默认是 ./logs Filename string `ck:"filename" def:"app.log"` // 文件名,含后缀, 默认:app.log TimeFormat string `ck:"time-format" def:"2006-01-02 15:04:05.000"` // 时间格式,默认是 2006-01-02 15:04:05.000 MaxSize int `ck:"max-size" def:"500"` // 单个配置文件大小最大限制,单位:M,默认是 500 M MaxBackups int `ck:"max-backups" def:"30"` // 最多保留多少个日志文件,默认 30 MaxAge int `ck:"max-age" def:"30"` // 日志文件存活时间,单位:天,默认是30天 Compress bool `ck:"compress" def:"false"` // 是否需要自动gzip进行压缩,默认:false ConsoleLog bool `ck:"console-log" def:"false"` // 是否需要输出控制台日志,默认是 false CallerSkipOffset int `ck:"caller-skip-offset" def:"0"` // 输出日志时候,计算输入日志的日志所在文件和行数偏移,一般给应用进行二次封装使用,正负数都可以 }
* 日志配置
func (*Properties) Equals ¶
func (p *Properties) Equals(properties *Properties) bool
type TraceIdGenerator ¶
* TraceId 生成器, 允许用户自定义
type ZapLogger ¶
type ZapLogger struct { Level Level // 日志级别 // contains filtered or unexported fields }
func (*ZapLogger) DebugWithContext ¶
func (*ZapLogger) DebugfWithContext ¶
func (*ZapLogger) ErrorWithContext ¶
func (*ZapLogger) ErrorfWithContext ¶
func (*ZapLogger) FatalWithContext ¶
func (*ZapLogger) FatalfWithContext ¶
func (*ZapLogger) InfoWithContext ¶
func (*ZapLogger) InfofWithContext ¶
func (*ZapLogger) IsDebugEnabled ¶
func (*ZapLogger) IsErrorEnabled ¶
func (*ZapLogger) IsFatalEnabled ¶
func (*ZapLogger) IsInfoEnabled ¶
func (*ZapLogger) IsWarnEnabled ¶
func (*ZapLogger) WarnWithContext ¶
Click to show internal directories.
Click to hide internal directories.