Documentation
¶
Index ¶
- Constants
- func Close() error
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorw(msg string, fields ...LogField)
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Infow(msg string, fields ...LogField)
- func SetLevel(c gofkConfs.LogConfig)
- func SetUp(c gofkConfs.LogConfig) error
- func SetWriter(w Writer)
- func Slow(v ...interface{})
- func Slowf(format string, v ...interface{})
- func Sloww(msg string, fields ...LogField)
- func Stat(v ...interface{})
- func Statf(format string, v ...interface{})
- func Statw(msg string, fields ...LogField)
- type DailyRotateRule
- type LogField
- type LogOptionFunc
- type LoggerInter
- type RotateLogger
- type RotateRule
- type Writer
Constants ¶
View Source
const ( // InfoLevel logs everything InfoLevel uint32 = iota // ErrorLevel includes errors ErrorLevel // StatLevel includes stat StatLevel // SevereLevel only log severe messages SevereLevel )
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf writes v with format into error log.
Types ¶
type DailyRotateRule ¶
type DailyRotateRule struct {
// contains filtered or unexported fields
}
DailyRotateRule 日志规则实现(按天)
func (*DailyRotateRule) BackupFileName ¶
func (r *DailyRotateRule) BackupFileName() string
BackupFileName 形成备份文件的文件名 使用 filename、delimiter 和当前日期(通过调用 getNowDate() 函数获取)按照一定的格式组合起来。
func (*DailyRotateRule) MarkRotated ¶
func (r *DailyRotateRule) MarkRotated()
MarkRotated 调用 getNowDate() 函数来获取当前的日期,并将其赋值给 r 的 rotatedTime 字段。 这个操作表示日志文件已经被轮转,并将轮转的时间更新为当前时间。
func (*DailyRotateRule) OutDatedFiles ¶
func (r *DailyRotateRule) OutDatedFiles() []string
OutDatedFiles 用于返回超过保留天数的日志文件列表。
func (*DailyRotateRule) ShallRotate ¶
func (r *DailyRotateRule) ShallRotate() bool
ShallRotate 判断是否需要进行切割,通过日期时间判断 @response true 需要切割 @response false 不需要切割
type LogOptionFunc ¶
type LogOptionFunc func(options *logOptions)
func WithCoolDownMillis ¶
func WithCoolDownMillis(millis int) LogOptionFunc
WithCoolDownMillis customizes logging on writing call stack interval.
func WithGzip ¶
func WithGzip() LogOptionFunc
WithGzip customizes logging to automatically gzip the log files.
func WithKeepDays ¶
func WithKeepDays(days int) LogOptionFunc
WithKeepDays customizes logging to keep logs with days.
type LoggerInter ¶
type LoggerInter interface { Error(...interface{}) Errorf(string, ...interface{}) Errorw(string, ...LogField) Info(...interface{}) Infof(string, ...interface{}) Infow(string, ...LogField) Slow(...interface{}) Slowf(string, ...interface{}) Sloww(string, ...LogField) WithContext(ctx context.Context) LoggerInter WithDuration(time.Duration) LoggerInter }
func WithContext ¶
func WithContext(ctx context.Context) LoggerInter
type RotateLogger ¶
type RotateLogger struct {
// contains filtered or unexported fields
}
RotateLogger 结构体是一个日志切割的实现。 需要实现 io.{Closer,Writer} 接口方法,从而实现写和关操作。
func NewLogger ¶
func NewLogger(filename string, rule RotateRule, compress bool) (*RotateLogger, error)
func (*RotateLogger) Close ¶
func (l *RotateLogger) Close() error
Close 关闭文件 RotateLogger,trait io.Closer
type RotateRule ¶
type RotateRule interface { BackupFileName() string MarkRotated() OutDatedFiles() []string ShallRotate() bool }
func DefaultRotateRule ¶
func DefaultRotateRule(filename, delimiter string, days int, gzip bool) RotateRule
Click to show internal directories.
Click to hide internal directories.