Simple, pretty logger for your Go apps.
log := logs.Default()
log.WithGroup("grouped").Debug("debug line", "path", "console_test.go")
log.Info("some info")
log.Warn("some warning")
log.Error("an error", "err", errors.New("oh no"))
- Compatible with slog
- Pretty
console
handler for terminals - Adds a level filter handler
- Adds a concurrent multi-logger
go get github.com/matthewmueller/logs
// Go with the default logger
log := logs.Default()
// Or configure
log = logs.New(
logs.Multi(
logs.Filter(slog.LevelInfo, logs.Console(os.Stderr)),
slog.NewJSONHandler(os.Stderr, nil),
),
)
log.WithGroup("hello").Debug("world", "args", 10)
log.Info("hello", "planet", "world", "args", 10)
log.Warn("hello", "planet", "world", "args", 10)
log.Error("hello world", "planet", "world", "args", 10)
// Integrates well with other libraries because log is still a *slog.Logger
var logger *slog.Logger = log
logger.WithGroup("hello").Debug("world", "args", 10)
logger.Info("hello", "planet", "world", "args", 10)
logger.Warn("hello", "planet", "world", "args", 10)
logger.Error("hello world", slog.String("planet", "world"), "args", 10)
- Matt Mueller (@mattmueller)
MIT