MCPcopy Create free account
hub / github.com/coder/slog / Make

Function Make

sloggers/slogtest/t.go:61–82  ·  view source on GitHub ↗

Make creates a Logger that writes logs to tb in a human-readable format.

(tb testing.TB, opts *Options)

Source from the content-addressed store, hash-verified

59
60// Make creates a Logger that writes logs to tb in a human-readable format.
61func Make(tb testing.TB, opts *Options) slog.Logger {
62 if opts == nil {
63 opts = &Options{}
64 }
65 if opts.IgnoredErrorIs == nil {
66 opts.IgnoredErrorIs = DefaultIgnoredErrorIs
67 }
68
69 sink := &testSink{
70 tb: tb,
71 opts: opts,
72 }
73 if !opts.SkipCleanup {
74 tb.Cleanup(func() {
75 sink.mu.Lock()
76 defer sink.mu.Unlock()
77 sink.testDone = true
78 })
79 }
80
81 return slog.Make(sink)
82}
83
84type testSink struct {
85 tb testing.TB

Callers 8

TestIgnoreErrorsFunction · 0.92
TestIgnoreErrorFnFunction · 0.92
TestCleanupFunction · 0.92
TestSkipCleanupFunction · 0.92
TestUnmarshalableFunction · 0.92
lFunction · 0.70

Calls 1

CleanupMethod · 0.80

Tested by 7

TestIgnoreErrorsFunction · 0.74
TestIgnoreErrorFnFunction · 0.74
TestCleanupFunction · 0.74
TestSkipCleanupFunction · 0.74
TestUnmarshalableFunction · 0.74