MCPcopy
hub / github.com/tinyauthapp/tinyauth / TestLogStreamField

Function TestLogStreamField

internal/utils/tlog/log_wrapper_test.go:67–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestLogStreamField(t *testing.T) {
68 var buf bytes.Buffer
69
70 cfg := config.LogConfig{
71 Level: "info",
72 Json: true,
73 Streams: config.LogStreams{
74 HTTP: config.LogStreamConfig{Enabled: true},
75 App: config.LogStreamConfig{Enabled: true},
76 Audit: config.LogStreamConfig{Enabled: true},
77 },
78 }
79
80 logger := tlog.NewLogger(cfg)
81
82 // Override output for HTTP logger to capture output
83 logger.HTTP = logger.HTTP.Output(&buf)
84
85 logger.HTTP.Info().Msg("test message")
86
87 var logEntry map[string]interface{}
88 err := json.Unmarshal(buf.Bytes(), &logEntry)
89 assert.NilError(t, err)
90
91 assert.Equal(t, "http", logEntry["log_stream"])
92 assert.Equal(t, "test message", logEntry["message"])
93}

Callers

nothing calls this directly

Calls 1

NewLoggerFunction · 0.92

Tested by

no test coverage detected