Make creates a Logger that writes logs to tb in a human-readable format.
(tb testing.TB, opts *Options)
| 59 | |
| 60 | // Make creates a Logger that writes logs to tb in a human-readable format. |
| 61 | func 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 | |
| 84 | type testSink struct { |
| 85 | tb testing.TB |