https://github.com/bingoohuang/golog
golog,支持:
- 日志格式化标准
- 日志级别颜色
- 按天/大小滚动
- 自动压缩
- 自动删除
- 自动日志文件名
- logrus一行集成
Integration with logrus
Use default settings:
func init() {
golog.SetupLogrus(nil, "")
}
Customize the settings:
func init() {
golog.SetupLogrus(nil, "level=debug,rotate=.yyyy-MM-dd-HH,maxAge=5d,gzipAge=1d")
}
Specifications
name | default value | description |
---|---|---|
level | info | log level to record (debug/info/warn/error) |
file | ~/logs/{bin}.log | base log file name |
rotate | .yyyy-MM-dd | time rotate pattern(full pattern: yyyy-MM-dd HH:mm)[Split according to the Settings of the last bit] |
maxAge | 30d | max age to keep log files (unit m/h/d/w) |
gzipAge | 3d | gzip aged log files (unit m/h/d/w) |
maxSize | 100M | max size to rotate log files (unit K/M/K/KiB/MiB/GiB/KB/MB/GB) |
printColor | true | print color on the log level or not, only for stdout=true |
printCall | true | print caller file:line or not (performance slow) |
stdout | true | print the log to stdout at the same time or not |
simple | false | simple to print log (not print [PID --- ThreadID TraceID]) |
网友评论