MCPcopy
hub / github.com/go-gorm/gorm / TestSlogLogger

Function TestSlogLogger

logger/slog_test.go:14–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestSlogLogger(t *testing.T) {
15 buf := &bytes.Buffer{}
16 handler := slog.NewTextHandler(buf, &slog.HandlerOptions{AddSource: true})
17 logger := NewSlogLogger(slog.New(handler), Config{LogLevel: Info})
18
19 logger.Trace(context.Background(), time.Now(), func() (string, int64) {
20 return "select count(*) from users", 0
21 }, nil)
22
23 if strings.Contains(buf.String(), "gorm/logger/slog.go") {
24 t.Error("Found internal slog.go reference in caller frame. Expected only test file references.")
25 }
26
27 if !strings.Contains(buf.String(), "gorm/logger/slog_test.go") {
28 t.Error("Missing expected test file reference. 'gorm/logger/slog_test.go' should appear in caller frames.")
29 }
30}

Callers

nothing calls this directly

Calls 6

NewSlogLoggerFunction · 0.85
ContainsMethod · 0.80
NewMethod · 0.65
TraceMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected