MCPcopy
hub / github.com/rs/zerolog / TestSlogHandler_MultipleAttrs

Function TestSlogHandler_MultipleAttrs

slog_test.go:339–363  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

337}
338
339func TestSlogHandler_MultipleAttrs(t *testing.T) {
340 var buf bytes.Buffer
341 logger := newSlogLogger(&buf)
342
343 logger.Info("multi",
344 slog.String("a", "1"),
345 slog.Int("b", 2),
346 slog.Bool("c", true),
347 slog.Float64("d", 3.5),
348 )
349
350 m := decodeJSON(t, &buf)
351 if m["a"] != "1" {
352 t.Errorf("expected a=1, got %v", m["a"])
353 }
354 if m["b"] != float64(2) {
355 t.Errorf("expected b=2, got %v", m["b"])
356 }
357 if m["c"] != true {
358 t.Errorf("expected c=true, got %v", m["c"])
359 }
360 if m["d"] != 3.5 {
361 t.Errorf("expected d=3.5, got %v", m["d"])
362 }
363}
364
365func TestSlogHandler_LogValuer(t *testing.T) {
366 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 7

newSlogLoggerFunction · 0.85
decodeJSONFunction · 0.85
InfoMethod · 0.65
StringMethod · 0.45
IntMethod · 0.45
BoolMethod · 0.45
Float64Method · 0.45

Tested by

no test coverage detected