Documentation ¶
Index ¶
- Constants
- Variables
- func ClearAll()
- func CloseAll() (err error)
- func DefaultFormatter(lv string, alert string, format string) string
- func InitGlobalRoller(roller string) error
- func IsLogRollerSubdirective(subdir string) bool
- func PutLogBuffer(buf LogBuffer) error
- func Reopen() (err error)
- func ToggleLogger(p string, disable bool) bool
- type ContextLogger
- type ErrorLogger
- type Level
- type LogBuffer
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Disable() bool
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Fatalln(args ...interface{})
- func (l *Logger) Print(buf LogBuffer, discard bool) error
- func (l *Logger) Printf(format string, args ...interface{})
- func (l *Logger) Println(args ...interface{})
- func (l *Logger) Reopen() error
- func (l *Logger) Toggle(disable bool)
- func (l *Logger) Write(p []byte) (n int, err error)
- type LoggerInfo
- type Roller
- type RollerHandler
- type SimpleContextLog
- func (l *SimpleContextLog) Alertf(ctx context.Context, alert string, format string, args ...interface{})
- func (l *SimpleContextLog) Debugf(ctx context.Context, format string, args ...interface{})
- func (l *SimpleContextLog) Errorf(ctx context.Context, format string, args ...interface{})
- func (l *SimpleContextLog) Fatalf(ctx context.Context, format string, args ...interface{})
- func (l *SimpleContextLog) Infof(ctx context.Context, format string, args ...interface{})
- func (l *SimpleContextLog) Tracef(ctx context.Context, format string, args ...interface{})
- func (l *SimpleContextLog) Warnf(ctx context.Context, format string, args ...interface{})
- type SimpleErrorLog
- func (l *SimpleErrorLog) Alertf(alert string, format string, args ...interface{})
- func (l *SimpleErrorLog) Debugf(format string, args ...interface{})
- func (l *SimpleErrorLog) Errorf(format string, args ...interface{})
- func (l *SimpleErrorLog) Fatalf(format string, args ...interface{})
- func (l *SimpleErrorLog) GetLogLevel() Level
- func (l *SimpleErrorLog) Infof(format string, args ...interface{})
- func (l *SimpleErrorLog) SetLogLevel(level Level)
- func (l *SimpleErrorLog) Tracef(format string, args ...interface{})
- func (l *SimpleErrorLog) Warnf(format string, args ...interface{})
Constants ¶
Variables ¶
var ErrChanFull = errors.New("channel is full")
var ( // error ErrReopenUnsupported = errors.New("reopen unsupported") )
Functions ¶
func IsLogRollerSubdirective ¶
IsLogRollerSubdirective is true if the subdirective is for the log roller.
func PutLogBuffer ¶
PutLogBuffer puts a LogBuffer back to logPool
func ToggleLogger ¶
Types ¶
type ContextLogger ¶
type ContextLogger interface { Alertf(ctx context.Context, alert string, format string, args ...interface{}) Infof(ctx context.Context, format string, args ...interface{}) Debugf(ctx context.Context, format string, args ...interface{}) Warnf(ctx context.Context, format string, args ...interface{}) Errorf(ctx context.Context, format string, args ...interface{}) Tracef(ctx context.Context, format string, args ...interface{}) Fatalf(ctx context.Context, format string, args ...interface{}) // SetLogLevel updates the log level SetLogLevel(Level) // GetLogLevel returns the logger's level GetLogLevel() Level // Toggle disable/enable the logger Toggle(disable bool) }
var DefaultContextLogger ContextLogger
type ErrorLogger ¶
type ErrorLogger interface { Alertf(alert string, format string, args ...interface{}) Infof(format string, args ...interface{}) Debugf(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Tracef(format string, args ...interface{}) Fatalf(format string, args ...interface{}) // SetLogLevel updates the log level SetLogLevel(Level) // GetLogLevel returns the logger's level GetLogLevel() Level // Toggle disable/enable the logger Toggle(disable bool) Disable() bool }
ErrorLogger generates lines of output to an io.Writer ErrorLogger generates lines of output to an io.Writer
var DefaultLogger ErrorLogger
type LogBuffer ¶
type LogBuffer struct {
// contains filtered or unexported fields
}
LogBuffer is an implementation of api.IoBuffer that used in log package, to distinguish it from api.IoBuffer nolint
func GetLogBuffer ¶
GetLogBuffer returns a LogBuffer from logPool
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a basic sync logger implement, contains unexported fields The Logger Function contains: Print(buffer LogBuffer, discard bool) error Printf(format string, args ...interface{}) Println(args ...interface{}) Fatalf(format string, args ...interface{}) Fatal(args ...interface{}) Fatalln(args ...interface{}) Close() error Reopen() error Toggle(disable bool)
func (*Logger) Print ¶
Print writes the final buffere to the buffer chan if discard is true and the buffer is full, returns an error If a LogBuffer needs to call Print N(N>1) times, the LogBuffer.Count(N-1) should be called or call LogBuffer.Count(1) N-1 times. If the N is 1, LogBuffer.Count should not be called.
type Roller ¶
type Roller struct { Filename string MaxSize int MaxAge int MaxBackups int Compress bool LocalTime bool // roller rotate time, if the MAxTime is configured, ignore the others config MaxTime int64 Handler RollerHandler }
roller implements a type that provides a rolling logger.
func ParseRoller ¶
ParseRoller parses roller contents out of c.
func (Roller) GetLogWriter ¶
GetLogWriter returns an io.Writer that writes to a rolling logger. it is careful to create only one log writer per log file, even if the log file is shared by different sites or middlewares. This ensures that rolling is synchronized, since a process (or multiple processes) should not create more than one roller on the same file at the same time. See issue #1363.
type RollerHandler ¶
type RollerHandler func(l *LoggerInfo)
type SimpleContextLog ¶
type SimpleContextLog struct {
*SimpleErrorLog
}
SimpleComtextLog is a wrapper of SimpleErrorLog
func (*SimpleContextLog) Alertf ¶
func (l *SimpleContextLog) Alertf(ctx context.Context, alert string, format string, args ...interface{})
func (*SimpleContextLog) Debugf ¶
func (l *SimpleContextLog) Debugf(ctx context.Context, format string, args ...interface{})
func (*SimpleContextLog) Errorf ¶
func (l *SimpleContextLog) Errorf(ctx context.Context, format string, args ...interface{})
func (*SimpleContextLog) Fatalf ¶
func (l *SimpleContextLog) Fatalf(ctx context.Context, format string, args ...interface{})
func (*SimpleContextLog) Infof ¶
func (l *SimpleContextLog) Infof(ctx context.Context, format string, args ...interface{})
type SimpleErrorLog ¶
type SimpleErrorLog struct { *Logger Formatter func(lv string, alert string, format string) string Level Level }
func (*SimpleErrorLog) Alertf ¶
func (l *SimpleErrorLog) Alertf(alert string, format string, args ...interface{})
func (*SimpleErrorLog) Debugf ¶
func (l *SimpleErrorLog) Debugf(format string, args ...interface{})
func (*SimpleErrorLog) Errorf ¶
func (l *SimpleErrorLog) Errorf(format string, args ...interface{})
func (*SimpleErrorLog) Fatalf ¶
func (l *SimpleErrorLog) Fatalf(format string, args ...interface{})
func (*SimpleErrorLog) GetLogLevel ¶
func (l *SimpleErrorLog) GetLogLevel() Level
func (*SimpleErrorLog) Infof ¶
func (l *SimpleErrorLog) Infof(format string, args ...interface{})
func (*SimpleErrorLog) SetLogLevel ¶
func (l *SimpleErrorLog) SetLogLevel(level Level)
func (*SimpleErrorLog) Tracef ¶
func (l *SimpleErrorLog) Tracef(format string, args ...interface{})
func (*SimpleErrorLog) Warnf ¶
func (l *SimpleErrorLog) Warnf(format string, args ...interface{})