Golang日志组件

2020-07-16  本文已影响0人  池边树下

https://github.com/bingoohuang/golog

golog,支持:

  1. 日志格式化标准
  2. 日志级别颜色
  3. 按天/大小滚动
  4. 自动压缩
  5. 自动删除
  6. 自动日志文件名
  7. 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])

上一篇下一篇

猜你喜欢

热点阅读