MCPcopy
hub / github.com/redpanda-data/console / TestLoggerWith

Function TestLoggerWith

backend/pkg/logger/logger_test.go:193–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

191}
192
193func TestLoggerWith(t *testing.T) {
194 var buf bytes.Buffer
195 logger := NewSlogLogger(
196 WithOutput(&buf),
197 WithFormat(FormatJSON), // Explicitly use JSON mode for predictable output
198 )
199
200 // Create a child logger with additional fields
201 childLogger := logger.With(slog.String("request_id", "123"), slog.String("user", "test-user"))
202
203 childLogger.Info("child logger message")
204
205 output := buf.String()
206 assert.Contains(t, output, `"request_id":"123"`)
207 assert.Contains(t, output, `"user":"test-user"`)
208 assert.Contains(t, output, "child logger message")
209}
210
211func TestStructuredLogging(t *testing.T) {
212 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 4

NewSlogLoggerFunction · 0.85
WithOutputFunction · 0.85
WithFormatFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…