feat: add support for configuring a debug logger#148
Conversation
The mutex is used internally only, we don't want our clients to be able to lock/unlock it.
We will be constructing the logger internally, instead of asking clients to provide it for us.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v4 #148 +/- ##
==========================================
+ Coverage 50.96% 55.97% +5.01%
==========================================
Files 5 5
Lines 520 720 +200
==========================================
+ Hits 265 403 +138
- Misses 235 293 +58
- Partials 20 24 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Also, drop the `total` and `interaction_count` fields -- we already log it during cassette loading, so it is redundant in a way.
… handler and blocked unsafe methods
These debug events don't bring any additional context, so drop them.
|
@marco-m , a bunch of other places got debug events as well, please check them as well, thanks! |
|
Hello @dnaeon, I did a first pass. Is there anything specific you want another pair of eyes for ? |
Thanks a lot, @marco-m ! I guess the real question is whether this change is helpful for debugging as the original request in #108 Unfortunately I don't think we would be able to provide a nice diff-like feature because of the reasons I've described in #108 |
Yes, your explanations in #108 were very clear and helped me understand the constraints. From my point of view, this is already a great improvement. Thank you! |
This PR adds support for configuring a debug logger for inspecting how the recorder adds/records/replays interactions.
The
recorder.WithDebugWriteroption allows API clients to specify their ownio.Writer, which will be used to configure anslog.Loggerfor emitting debug-only events.By default the
RecorderandCassettewill be configured withio.Discardwriter, so no debug logs will be emitted.In order to enable debug logger for existing test cases without having to set the
recorder.WithDebugLoggeroption API clients can set theVCR_DEBUG=trueenv var, which will configure a logger emitting events toos.Stderr.Related to #108
cc: @marco-m , @akosyakov