Documentation ¶
Index ¶
- Constants
- Variables
- func Alert(v string)
- func Close() error
- func CollectSysLog()
- func Disable()
- func Error(v ...interface{})
- func ErrorCaller(callDepth int, v ...interface{})
- func ErrorCallerf(callDepth int, format string, v ...interface{})
- func ErrorStack(v ...interface{})
- func ErrorStackf(format string, v ...interface{})
- func Errorf(format string, v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Must(err error)
- func MustSetup(c LogConf)
- func NewLessWriter(writer io.Writer, milliseconds int) *lessWriter
- func SetLevel(level uint32)
- func SetUp(c LogConf) error
- func Severe(v ...interface{})
- func Severef(format string, v ...interface{})
- func Slow(v ...interface{})
- func Slowf(format string, v ...interface{})
- func Stat(v ...interface{})
- func Statf(format string, v ...interface{})
- type DailyRotateRule
- type LessLogger
- type LogConf
- type LogOption
- type Logger
- type RotateLogger
- type RotateRule
Constants ¶
View Source
const ( // InfoLevel logs everything InfoLevel = iota // ErrorLevel includes errors, slows, stacks ErrorLevel // SevereLevel only log severe messages SevereLevel )
Variables ¶
View Source
var ( ErrLogPathNotSet = errors.New("log path must be set") ErrLogNotInitialized = errors.New("log not initialized") ErrLogServiceNameNotSet = errors.New("log service name must be set") )
View Source
var ErrLogFileClosed = errors.New("error: log file closed")
Functions ¶
func ErrorCaller ¶
func ErrorCaller(callDepth int, v ...interface{})
func ErrorCallerf ¶
func ErrorStack ¶
func ErrorStack(v ...interface{})
func ErrorStackf ¶
func ErrorStackf(format string, v ...interface{})
func NewLessWriter ¶
Types ¶
type DailyRotateRule ¶
type DailyRotateRule struct {
// contains filtered or unexported fields
}
func (*DailyRotateRule) BackupFileName ¶
func (r *DailyRotateRule) BackupFileName() string
func (*DailyRotateRule) MarkRotated ¶
func (r *DailyRotateRule) MarkRotated()
func (*DailyRotateRule) OutdatedFiles ¶
func (r *DailyRotateRule) OutdatedFiles() []string
func (*DailyRotateRule) ShallRotate ¶
func (r *DailyRotateRule) ShallRotate() bool
type LessLogger ¶
type LessLogger struct {
// contains filtered or unexported fields
}
func NewLessLogger ¶
func NewLessLogger(milliseconds int) *LessLogger
func (*LessLogger) Error ¶
func (logger *LessLogger) Error(v ...interface{})
func (*LessLogger) Errorf ¶
func (logger *LessLogger) Errorf(format string, v ...interface{})
type LogConf ¶
type LogConf struct { ServiceName string `json:",optional"` Mode string `json:",default=console,options=console|file|volume"` Path string `json:",default=logs"` Level string `json:",default=info,options=info|error|severe"` Compress bool `json:",optional"` KeepDays int `json:",optional"` StackCooldownMillis int `json:",default=100"` }
type LogOption ¶
type LogOption func(options *logOptions)
func WithCooldownMillis ¶
func WithKeepDays ¶
type Logger ¶
type Logger interface { Error(...interface{}) Errorf(string, ...interface{}) Info(...interface{}) Infof(string, ...interface{}) Slow(...interface{}) Slowf(string, ...interface{}) WithDuration(time.Duration) Logger }
func WithContext ¶
func WithDuration ¶
type RotateLogger ¶
type RotateLogger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(filename string, rule RotateRule, compress bool) (*RotateLogger, error)
func (*RotateLogger) Close ¶
func (l *RotateLogger) Close() error
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.