// Package log provides a thin slog wrapper so callers can configure the level // from a single string ("debug"|"info"|"warn"|"error"). package log import ( "log/slog" "os" "strings" ) // New returns a slog.Logger writing JSON to stdout at the given level. An // unknown level falls back to info. func New(level string) *slog.Logger { var lvl slog.Level switch strings.ToLower(level) { case "debug": lvl = slog.LevelDebug case "info": lvl = slog.LevelInfo case "warn": lvl = slog.LevelWarn case "error": lvl = slog.LevelError default: lvl = slog.LevelInfo } h := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: lvl}) return slog.New(h) }