1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
package gcp
import (
"context"
"log/slog"
"testing"
)
func TestHandler(t *testing.T) {
ctx := context.Background()
l := slog.New(NewHandler(slog.LevelInfo))
l.With("level", "INFO").Log(ctx, slog.LevelInfo, "hello world") // okay
l.With("level", "INFO").Log(ctx, slog.LevelWarn, "hello world") // weird, but okay (info)
// These should not panic.
l.With("level", nil).Log(ctx, slog.LevelInfo, "hello world")
l.With("level", 123).Log(ctx, slog.LevelInfo, "hello world")
l.With("level", map[string]string{}).Log(ctx, slog.LevelInfo, "hello world")
}
|