Skip to content
/ go-log Public

uber-go/zap wrapper with log rotation

License

Notifications You must be signed in to change notification settings

kuoruan/go-log

Repository files navigation

Uber Zap logger wrapper with log rotation

Installation

go get -u go.kuoruan.net/log

Quick Start

Use the global logger.

package main

import "go.kuoruan.net/log"

func main() {
    log.SetOptions(log.Development())

    log.Debug("this is debug log")
}

Or create new:

package main

import "go.kuoruan.net/log"

func main() {
    logger := log.New(
        log.RotationConfig{
            MaxSize: 500, // MB
            MaxAge: 3, // days
            MaxBackups: 7,
            LocalTime: true,
            Compress: true,
        },
        log.AddCaller(), 
        log.WithLogDirs("log"), 
        log.LogToStdout(),
    )
    
    logger.Info("This is info log")
}