Leadrive / logger

an implement of pushing entries to grafana/loki with logrus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logger combines a wrapper of logrus and schoentoon/logrus-loki, not only use stdout as standard output, but alse add a new file writer output. It can easily sending entries of logrus to loki without docker container.

Usage

func main() {
    Init("game server", true, "")
	EnableLoki(true)
	SetLokiConfig("http://localhost:3100/api/prom/push", 1024, 5)
	Info("test")
	Warn("warn")
	Error("error")

	err := errors.New("error 404 found")
	fields := map[string]interface{}{
		"error": err,
		"url":   "http://google.com",
	}
	WithFieldsWarn(fields, "ping to google")
}

About

an implement of pushing entries to grafana/loki with logrus


Languages

Language:Go 100.0%