Skip to content

logger based on logrus, file-rotatelogs, flshook

Notifications You must be signed in to change notification settings

fAROSIA/logcomm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logcomm

Logcomm is a logger for GO, based on Logrus, File-rotatelogs and Lfshook.

Install

$ go get ...

Usage

It provides two ways of logging:

  • print in single file by using NewMergedLogger(logPath string, logName string)
  • print in seperated files of each level with rotation by using NewSeperatedLogger(logPath string)

Logger that function returns is a logrus.Logger, you can using logrus' API to do everything you want to.

const (
	Panic = iota
	Fatal
	Error
	Warn
	Info
	Debug
	Trace
)

path := "/data/test/log"
// return a mergedLogger
logMerged := logcomm.NewMergedLogger(path, "merge")
// return a seperatedLogger
logSeperated := logcomm.NewSeperatedLogger(path)

logMerged.Logf(Error, "this is fatal %d:%d:%d", time.Now().Hour(), time.Now().Minute(), time.Now().Second())
logMerged.Logf(Fatal, "this is fatal %d:%d:%d", time.Now().Hour(), time.Now().Minute(), time.Now().Second())
// 

Maintainers

@fAROSIA

About

logger based on logrus, file-rotatelogs, flshook

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages