Skip to content

log for golang! combine zerolog and file-rotatelogs.

License

Notifications You must be signed in to change notification settings

RocksonZeta/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logger

combine zerolog and file-rotatelogs.

Install

go get -u github.com/RocksonZeta/logger

Example

package logger_test

import (
	"errors"
	"testing"

	"github.com/RocksonZeta/logger"
)

var options = logger.Options{Console: true, Level: "debug", File: "test_log.%Y%m%d.log", ForceNewFile: true, MaxAge: 1, ShowLocalIp: true}
var serviceLog logger.FileLogger = logger.NewLogger(options)

var log = serviceLog.WithPkg("good/service/users")

func TestLog(t *testing.T) {
	log.Trace().M("User").Func("TestWrite").Interface("user", User{Id: 1}).Send()
	log.Debug().M("User").Func("TestWrite").Str("sql", "select * from User where id=?").Int("id", 1).Send()
	log.Info().M("User").Func("Signin").Str("uid", "1").Msg("hello")
	log.Warn().M("User").Func("Signin").Str("uid", "1").Msg("bad user")
	log.Error().M("User").Stack().Err(errors.New("oh no")).Send()
}

type User struct {
	Id int
}

About

log for golang! combine zerolog and file-rotatelogs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages