MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestLogger_FormatMessage

Function TestLogger_FormatMessage

internal/logger/logger_test.go:333–356  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

331}
332
333func TestLogger_FormatMessage(t *testing.T) {
334 var buf bytes.Buffer
335 config := &Config{
336 Level: LevelInfo,
337 Output: &buf,
338 }
339
340 logger, err := NewLogger(config)
341 require.NoError(t, err)
342 defer logger.Close()
343
344 logger.Info("test message with %s and %d", "string", 42)
345
346 output := buf.String()
347 assert.Contains(t, output, "[INFO]")
348 assert.Contains(t, output, "test message with string and 42")
349
350 // Check timestamp format (should be present)
351 lines := strings.Split(strings.TrimSpace(output), "\n")
352 assert.True(t, len(lines) > 0)
353
354 // The timestamp should be in format [YYYY-MM-DD HH:MM:SS]
355 assert.Regexp(t, `\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\]`, lines[0])
356}
357
358func TestLogger_SetLevel(t *testing.T) {
359 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
InfoMethod · 0.95
NewLoggerFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected