Simple and useful log handling package in Golang
Get from Github:
go get github.com/golage/log
Import into your code:
import "github.com/golage/log"
Set output writer:
log.SetOutput(w)
Set minimum log level (default: LevelInfo):
log.SetLevel(log.LevelDebug)
Set log formatter (default: TextFormatter):
log.SetFormatter(log.NewTextFormatter)
log.SetFormatter(log.NewJSONFormatter)
log.SetFormatter(log.NewYAMLFormatter)
Set constants data in all logs:
log.SetConstant("key", "value")
Add data to log:
log.With(err)
log.Value("key", "value")
Write log:
log.Debug("message")
log.Info("message")
log.Warning("message")
log.Error("message")
log.Fatal("message")
For more see example