Versions in this module Expand all Collapse all v1 v1.7.7 Dec 24, 2024 v1.7.6 Dec 24, 2024 Changes in this version + const DebugLevel + const ErrorLevel + const InfoLevel + const SevereLevel + var ErrLogFileClosed = errors.New("error: log file closed") + var ErrLogPathNotSet = errors.New("log path must be set") + var ErrLogServiceNameNotSet = errors.New("log service name must be set") + var ExitOnFatal = syncx.ForAtomicBool(true) + func AddGlobalFields(fields ...LogField) + func AddWriter(w Writer) + func Alert(v string) + func Close() error + func CollectSysLog() + func ContextWithFields(ctx context.Context, fields ...LogField) context.Context + func Debug(v ...any) + func Debugf(format string, v ...any) + func Debugv(v any) + func Debugw(msg string, fields ...LogField) + func Disable() + func DisableStat() + func Error(v ...any) + func ErrorStack(v ...any) + func ErrorStackf(format string, v ...any) + func Errorf(format string, v ...any) + func Errorv(v any) + func Errorw(msg string, fields ...LogField) + func Info(v ...any) + func Infof(format string, v ...any) + func Infov(v any) + func Infow(msg string, fields ...LogField) + func Must(err error) + func MustSetup(c LogConf) + func SetLevel(level uint32) + func SetUp(c LogConf) (err error) + func SetWriter(w Writer) + func Severe(v ...any) + func Severef(format string, v ...any) + func Slow(v ...any) + func Slowf(format string, v ...any) + func Slowv(v any) + func Sloww(msg string, fields ...LogField) + func Stat(v ...any) + func Statf(format string, v ...any) + func WithColor(text string, colour color.Color) string + func WithColorPadding(text string, colour color.Color) string + func WithFields(ctx context.Context, fields ...LogField) context.Context + type DailyRotateRule struct + func (r *DailyRotateRule) BackupFileName() string + func (r *DailyRotateRule) MarkRotated() + func (r *DailyRotateRule) OutdatedFiles() []string + func (r *DailyRotateRule) ShallRotate(_ int64) bool + type LessLogger struct + func NewLessLogger(milliseconds int) *LessLogger + func (logger *LessLogger) Error(v ...any) + func (logger *LessLogger) Errorf(format string, v ...any) + type LogConf struct + Compress bool + Encoding string + FileTimeFormat string + KeepDays int + Level string + MaxBackups int + MaxContentLength uint32 + MaxSize int + Mode string + Path string + Rotation string + ServiceName string + StackCooldownMillis int + Stat bool + TimeFormat string + type LogField struct + Key string + Value any + func Field(key string, value any) LogField + type LogOption func(options *logOptions) + func WithCooldownMillis(millis int) LogOption + func WithGzip() LogOption + func WithKeepDays(days int) LogOption + func WithMaxBackups(count int) LogOption + func WithMaxSize(size int) LogOption + func WithRotation(r string) LogOption + type Logger interface + Debug func(...any) + Debugf func(string, ...any) + Debugv func(any) + Debugw func(string, ...LogField) + Error func(...any) + Errorf func(string, ...any) + Errorv func(any) + Errorw func(string, ...LogField) + Info func(...any) + Infof func(string, ...any) + Infov func(any) + Infow func(string, ...LogField) + Slow func(...any) + Slowf func(string, ...any) + Slowv func(any) + Sloww func(string, ...LogField) + WithCallerSkip func(skip int) Logger + WithContext func(ctx context.Context) Logger + WithDuration func(d time.Duration) Logger + WithFields func(fields ...LogField) Logger + func WithCallerSkip(skip int) Logger + func WithContext(ctx context.Context) Logger + func WithDuration(d time.Duration) Logger + type RotateLogger struct + func NewLogger(filename string, rule RotateRule, compress bool) (*RotateLogger, error) + func (l *RotateLogger) Close() error + func (l *RotateLogger) Write(data []byte) (int, error) + type RotateRule interface + BackupFileName func() string + MarkRotated func() + OutdatedFiles func() []string + ShallRotate func(size int64) bool + func DefaultRotateRule(filename, delimiter string, days int, gzip bool) RotateRule + func NewSizeLimitRotateRule(filename, delimiter string, days, maxSize, maxBackups int, gzip bool) RotateRule + type SizeLimitRotateRule struct + func (r *SizeLimitRotateRule) BackupFileName() string + func (r *SizeLimitRotateRule) MarkRotated() + func (r *SizeLimitRotateRule) OutdatedFiles() []string + func (r *SizeLimitRotateRule) ShallRotate(size int64) bool + type Writer interface + Alert func(v any) + Close func() error + Debug func(v any, fields ...LogField) + Error func(v any, fields ...LogField) + Info func(v any, fields ...LogField) + Severe func(v any) + Slow func(v any, fields ...LogField) + Stack func(v any) + Stat func(v any, fields ...LogField) + func NewWriter(w io.Writer) Writer + func Reset() Writer