美文网首页
Golang日志组件

Golang日志组件

作者: 池边树下 | 来源:发表于2020-07-16 16:18 被阅读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])

    相关文章

      网友评论

          本文标题:Golang日志组件

          本文链接:https://www.haomeiwen.com/subject/vwaphktx.html