Documentation ¶
Index ¶
- Constants
- Variables
- func CloseAll() (err error)
- func DisableAllAccessLog()
- func InitDefaultLogger(output string, level Level) (err error)
- func InitGlobalRoller(roller string) error
- func IsLogRollerSubdirective(subdir string) bool
- func NewAccessLog(output string, format string) (types.AccessLog, error)
- func Reopen() (err error)
- func ToggleLogger(p string, disable bool) bool
- func UpdateErrorLoggerLevel(p string, level Level) bool
- type CreateErrorLoggerFunc
- type ErrorLogger
- type ErrorLoggerManager
- type Level
- type Logger
- func (l *Logger) Close() error
- 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 types.IoBuffer, 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 ProxyLogger
- type Roller
Constants ¶
const ( InfoPre string = "[INFO]" DebugPre string = "[DEBUG]" WarnPre string = "[WARN]" ErrorPre string = "[ERROR]" FatalPre string = "[FATAL]" TracePre string = "[TRACE]" )
const AccessLogLen = 1 << 8
Variables ¶
var ( DefaultDisableAccessLog bool ErrLogFormatUndefined = errors.New("access log format undefined") ErrEmptyVarDef = errors.New("access log format error: empty variable definition") ErrUnclosedVarDef = errors.New("access log format error: unclosed variable definition") )
RequestInfoFuncMap is a map which key is the format-key, value is the func to get corresponding string value
var ( DefaultLogger ErrorLogger StartLogger ErrorLogger Proxy ProxyLogger ErrNoLoggerFound = errors.New("no logger found in logger manager") )
var ( // error ErrReopenUnsupported = errors.New("reopen unsupported") )
Functions ¶
func DisableAllAccessLog ¶
func DisableAllAccessLog()
func InitDefaultLogger ¶
func IsLogRollerSubdirective ¶
IsLogRollerSubdirective is true if the subdirective is for the log roller.
func NewAccessLog ¶
NewAccessLog
func ToggleLogger ¶
ToggleLogger enable/disable the exists logger, include ErrorLogger and Logger
func UpdateErrorLoggerLevel ¶
UpdateErrorLoggerLevel updates the exists ErrorLogger's Level
Types ¶
type CreateErrorLoggerFunc ¶
type CreateErrorLoggerFunc func(output string, level Level) (ErrorLogger, error)
CreateErrorLoggerFunc creates a ErrorLogger implementation by output and level
type ErrorLogger ¶
type ErrorLogger interface { Println(args ...interface{}) Printf(format string, args ...interface{}) // Alertf is a wrapper of Errorf Alertf(errkey types.ErrorKey, 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{}) Fatal(args ...interface{}) Fatalln(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) }
ErrorLogger generates lines of output to an io.Writer
func CreateDefaultErrorLogger ¶
func CreateDefaultErrorLogger(output string, level Level) (ErrorLogger, error)
func GetOrCreateDefaultErrorLogger ¶
func GetOrCreateDefaultErrorLogger(p string, level Level) (ErrorLogger, error)
GetOrCreateDefaultErrorLogger used default create function
type ErrorLoggerManager ¶
type ErrorLoggerManager struct {
// contains filtered or unexported fields
}
ErrorLoggerManager manages error log can be updated dynamicly
func GetErrorLoggerManagerInstance ¶
func GetErrorLoggerManagerInstance() *ErrorLoggerManager
Default Export Functions
func (*ErrorLoggerManager) GetOrCreateErrorLogger ¶
func (mng *ErrorLoggerManager) GetOrCreateErrorLogger(p string, level Level, f CreateErrorLoggerFunc) (ErrorLogger, error)
GetOrCreateErrorLogger returns a ErrorLogger based on the output(p). If Logger not exists, and create function is not nil, creates a new logger
func (*ErrorLoggerManager) SetAllErrorLoggerLevel ¶
func (mng *ErrorLoggerManager) SetAllErrorLoggerLevel(level Level)
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 types.IoBuffer, 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)
type ProxyLogger ¶
type ProxyLogger interface { // Alertf is a wrapper of Errorf Alertf(ctx context.Context, errkey types.ErrorKey, 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{}) 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) }
ProxyLogger generates lines of output to an io.Writer, works for data flow
func CreateDefaultProxyLogger ¶
func CreateDefaultProxyLogger(output string, level Level) (ProxyLogger, error)
type Roller ¶
type Roller struct { Filename string MaxSize int MaxAge int MaxBackups int Compress bool LocalTime bool MaxTime int64 }
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. This should be called only from the main goroutine (like during server setup) because this method is not thread-safe; 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.