MCPcopy
hub / github.com/caddyserver/caddy / testLogger

Function testLogger

modules/caddyhttp/server_test.go:36–49  ·  view source on GitHub ↗

testLogger returns a logger and a buffer to which the logger writes. The buffer can be read for asserting log output.

(wf writeFunc)

Source from the content-addressed store, hash-verified

34// testLogger returns a logger and a buffer to which the logger writes. The
35// buffer can be read for asserting log output.
36func testLogger(wf writeFunc) *zap.Logger {
37 ws := nopSyncer(wf)
38 encoderCfg := zapcore.EncoderConfig{
39 MessageKey: "msg",
40 LevelKey: "level",
41 NameKey: "logger",
42 EncodeLevel: zapcore.LowercaseLevelEncoder,
43 EncodeTime: zapcore.ISO8601TimeEncoder,
44 EncodeDuration: zapcore.StringDurationEncoder,
45 }
46 core := zapcore.NewCore(zapcore.NewJSONEncoder(encoderCfg), ws, zap.DebugLevel)
47
48 return zap.New(core)
49}
50
51func TestServer_LogRequest(t *testing.T) {
52 s := &Server{}

Calls 1

nopSyncerTypeAlias · 0.85

Tested by

no test coverage detected