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

Function Test_CtxLogger

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

Source from the content-addressed store, hash-verified

211}
212
213func Test_CtxLogger(t *testing.T) {
214 initDefaultLogger()
215
216 var w byteSliceWriter
217 SetOutput(&w)
218
219 ctx := context.Background()
220
221 WithContext(ctx).Tracef("trace %s", work)
222 WithContext(ctx).Debugf("received %s order", work)
223 WithContext(ctx).Infof("starting %s", work)
224 WithContext(ctx).Warnf("%s may fail", work)
225 WithContext(ctx).Errorf("%s failed %d", work, 50)
226
227 require.Panics(t, func() {
228 WithContext(ctx).Panicf("%s panic", work)
229 })
230
231 require.Equal(t, "[Trace] trace work\n"+
232 "[Debug] received work order\n"+
233 "[Info] starting work\n"+
234 "[Warn] work may fail\n"+
235 "[Error] work failed 50\n"+
236 "[Panic] work panic\n", string(w.b))
237}
238
239// Test_WithContextTemplate runs serially because initDefaultLogger,
240// SetContextTemplate, MustSetContextTemplate, and SetOutput mutate package

Callers

nothing calls this directly

Calls 9

initDefaultLoggerFunction · 0.85
SetOutputFunction · 0.85
WithContextFunction · 0.85
TracefMethod · 0.65
DebugfMethod · 0.65
InfofMethod · 0.65
WarnfMethod · 0.65
ErrorfMethod · 0.65
PanicfMethod · 0.65

Tested by

no test coverage detected