/lo‧ki/ Finnish for log; to record something.
func main() {
l := "loki"
log := loki.New()
log.Info("hello from %s", l)
}go run main.go
2021/01/01 18:00:00 [INFO] hello from lokifunc main() {
log := loki.New()
log.Set(loki.ERROR)
log.Debug("this won't appear")
log.Error("error message")
}go run main.go
2021/01/01 18:00:00 [ERROR] error messagefunc main() {
log := loki.New()
log.WriteFile("/var/log/loki.log")
log.Info("hello /var/log")
}Loki supports logging directly out as a json string.
func main() {
log = loki.NewJsonLogger()
log.Info("some information from your application")
}go run main.go
{"timestamp":"2021-01-01T18:00:00.000000Z","message":"some information from your application","level":"INFO","caller":{"function":"main.main","line":3,"file":"/path/to/main.go"}}