Lightweight, structured logger for Go projects. It basically adds some functions to slog which I found missing (e.g. log*f functions and a logFatal function known from standard log package.). Slog is wrapped inside eslog so you can do everything which is possible with slog.
This project is intended to not have any dapendencies.
go get github.com/steffakasid/eslog@latest
package main
import (
"github.com/spf13/viper"
"github.com/steffakasid/eslog"
)
func main() {
viper.SetDefault("log.level", "info")
viper.SetDefault("log.format", "json")
// viper.ReadInConfig() // optional
cfg := eslog.Config{
Level: viper.GetString("log.level"),
Format: viper.GetString("log.format"),
}
logger, err := eslog.New(cfg)
if err != nil {
panic(err)
}
logger.Info("service started",
eslog.Field("version", "v0.1.0"),
)
}- log.level: debug|info|warn|error
- log.format: json|text
- output (optional): file path or stdout/stderr
PRs welcome. Please follow gofmt and golangci-lint rules.
Apache v2