MCPcopy
hub / github.com/gofiber/fiber / Test_LogfKeyAndValues

Function Test_LogfKeyAndValues

log/default_test.go:306–368  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

304}
305
306func Test_LogfKeyAndValues(t *testing.T) {
307 tests := []struct {
308 name string
309 format string
310 wantOutput string
311 fmtArgs []any
312 keysAndValues []any
313 level Level
314 }{
315 {
316 name: "test logf with debug level and key-values",
317 level: LevelDebug,
318 format: "",
319 fmtArgs: nil,
320 keysAndValues: []any{"name", "Bob", "age", 30},
321 wantOutput: "[Debug] name=Bob age=30\n",
322 },
323 {
324 name: "test logf with info level and key-values",
325 level: LevelInfo,
326 format: "",
327 fmtArgs: nil,
328 keysAndValues: []any{"status", "ok", "code", 200},
329 wantOutput: "[Info] status=ok code=200\n",
330 },
331 {
332 name: "test logf with warn level and key-values",
333 level: LevelWarn,
334 format: "",
335 fmtArgs: nil,
336 keysAndValues: []any{"error", "not found", "id", 123},
337 wantOutput: "[Warn] error=not found id=123\n",
338 },
339 {
340 name: "test logf with format and key-values",
341 level: LevelWarn,
342 format: "test",
343 fmtArgs: nil,
344 keysAndValues: []any{"error", "not found", "id", 123},
345 wantOutput: "[Warn] test error=not found id=123\n",
346 },
347 {
348 name: "test logf with one key",
349 level: LevelWarn,
350 format: "",
351 fmtArgs: nil,
352 keysAndValues: []any{"error"},
353 wantOutput: "[Warn] error=KEYVALS UNPAIRED\n",
354 },
355 }
356 for _, tt := range tests {
357 t.Run(tt.name, func(t *testing.T) {
358 var buf bytes.Buffer
359 l := &defaultLogger{
360 stdlog: log.New(&buf, "", 0),
361 level: tt.level,
362 depth: 4,
363 }

Callers

nothing calls this directly

Calls 3

privateLogwMethod · 0.95
StringMethod · 0.95
NewMethod · 0.65

Tested by

no test coverage detected