MCPcopy Create free account
hub / github.com/ankorstore/yokai / TestErrorLogging

Function TestErrorLogging

httpserver/logger_test.go:201–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func TestErrorLogging(t *testing.T) {
202 buffer := logtest.NewDefaultTestLogBuffer()
203
204 logger, err := log.NewDefaultLoggerFactory().Create(
205 log.WithOutputWriter(buffer),
206 log.WithLevel(zerolog.ErrorLevel),
207 )
208 assert.NoError(t, err)
209
210 echoLogger := httpserver.NewEchoLogger(logger)
211
212 echoLogger.Error("test regular message")
213 logtest.AssertHasLogRecord(t, buffer, map[string]interface{}{
214 "level": "error",
215 "message": "test regular message",
216 })
217
218 echoLogger.Errorf("test placeholder message: %s", "placeholder")
219 logtest.AssertHasLogRecord(t, buffer, map[string]interface{}{
220 "level": "error",
221 "message": "test placeholder message: placeholder",
222 })
223
224 echoLogger.Errorj(echologger.JSON{"message": "test json message"})
225 logtest.AssertHasLogRecord(t, buffer, map[string]interface{}{
226 "level": "error",
227 "message": "test json message",
228 })
229}
230
231func TestPrintLogging(t *testing.T) {
232 buffer := logtest.NewDefaultTestLogBuffer()

Callers

nothing calls this directly

Calls 4

ErrorMethod · 0.95
ErrorfMethod · 0.95
ErrorjMethod · 0.95
CreateMethod · 0.65

Tested by

no test coverage detected