Skip to content

Instantly share code, notes, and snippets.

@terut
terut / slogexmaple.go
Created September 7, 2023 15:39
slog example
func logRun() {
//ctx := context.Background()
replace := func(groups []string, a slog.Attr) slog.Attr {
switch {
case a.Key == slog.MessageKey:
return slog.Attr{Key: "message", Value: a.Value}
case a.Key == slog.LevelKey:
if l := a.Value.Any().(slog.Level); l == slog.LevelWarn {
return slog.String("severity", "WARNING")
}