Documentation ¶
Overview ¶
log library supported loglevel and logrotate.
loglevel:
Debug: 1‰ probability to write log with format [DEBUG]... Info: write info log with format [INFO]... Warning: write warning log with format [WARNING]... Error: write error log with stacktrace and format [ERROR]...
logrotate:
date: it will rename the log file to <name>_<yyyymmdd>.log in the next day. size: it will rename the log file to <name>.log.<n> when log size is more than limit size.
Index ¶
- Variables
- func Debug(fmt string, a ...interface{}) string
- func Error(fmt string, a ...interface{}) string
- func Files() []string
- func Flush()
- func Info(fmt string, a ...interface{}) string
- func Printf(fmt string, a ...interface{}) string
- func Println(v ...interface{}) string
- func SetDateRotate(cfg DateRotateConfig)
- func SetLevel(level Level)
- func SetSizeRotate(cfg SizeRotateConfig)
- func Warning(fmt string, a ...interface{}) string
- type DateRotateConfig
- type Level
- type Logger
- func (l *Logger) Debug(fmt string, a ...interface{}) string
- func (l *Logger) Error(fmt string, a ...interface{}) string
- func (l *Logger) Flush()
- func (l *Logger) Info(fmt string, a ...interface{}) string
- func (l *Logger) Printf(fmt string, a ...interface{}) string
- func (l *Logger) Warning(fmt string, a ...interface{}) string
- func (l *Logger) Write(data []byte) (int, error)
- type SizeRotateConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultLogger = Logger{ // contains filtered or unexported fields }
DefaultLogger default logger by log package
Functions ¶
Types ¶
type DateRotateConfig ¶
type DateRotateConfig struct { Level Level // log level Dir string // log file save directory, only used if WriteFile=true Name string // log file name, only used if WriteFile=true Rotate int // save rotated file count, only used if WriteFile=true WriteStdout bool // allow write to stdout WriteFile bool // allow write to file }
DateRotateConfig date logger config
type Logger ¶
Logger logger interface
func NewRotateDateLogger ¶
func NewRotateDateLogger(cfg DateRotateConfig) Logger
NewRotateDateLogger create logger by date rotate
func NewRotateSizeLogger ¶
func NewRotateSizeLogger(cfg SizeRotateConfig) Logger
NewRotateSizeLogger create logger rotate by file size
type SizeRotateConfig ¶
type SizeRotateConfig struct { Level Level // log level Dir string // log file save directory, only used if WriteFile=true Name string // log file name, only used if WriteFile=true Size int64 // rotate when file >= Size, only used if WriteFile=true Rotate int // save rotated file count, only used if WriteFile=true WriteStdout bool // allow write to stdout WriteFile bool // allow write to file }
SizeRoateConfig size logger config
Click to show internal directories.
Click to hide internal directories.