- soju raw connector with event playback and CHATHISTORY fallback - SQLite store with msgid de-dup and retention job - Mentions + Pushover + tuning; structured JSON logs - Summaries: concise, link-following, multi-line grouping - HTTP: /healthz, /ready, /tail, /trigger, /metrics - Docker: distroless, healthcheck, version metadata - Docs: README, CHANGELOG, compose
24 lines
543 B
Go
24 lines
543 B
Go
package logging
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// New returns a JSON slog logger configured to the provided level string (debug, info, warn, error).
|
|
func New(level string) *slog.Logger {
|
|
lvl := slog.LevelInfo
|
|
switch strings.ToLower(strings.TrimSpace(level)) {
|
|
case "debug":
|
|
lvl = slog.LevelDebug
|
|
case "info", "":
|
|
lvl = slog.LevelInfo
|
|
case "warn", "warning":
|
|
lvl = slog.LevelWarn
|
|
case "err", "error":
|
|
lvl = slog.LevelError
|
|
}
|
|
h := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: lvl})
|
|
return slog.New(h)
|
|
}
|