Skip to content

feat: add support for configuring a debug logger#148

Merged
dnaeon merged 25 commits into
v4from
feat/with-debug-logger
Jun 25, 2026
Merged

feat: add support for configuring a debug logger#148
dnaeon merged 25 commits into
v4from
feat/with-debug-logger

Conversation

@dnaeon

@dnaeon dnaeon commented Jun 22, 2026

Copy link
Copy Markdown
Owner

This PR adds support for configuring a debug logger for inspecting how the recorder adds/records/replays interactions.

The recorder.WithDebugWriter option allows API clients to specify their own io.Writer, which will be used to configure an slog.Logger for emitting debug-only events.

By default the Recorder and Cassette will be configured with io.Discard writer, so no debug logs will be emitted.

In order to enable debug logger for existing test cases without having to set the recorder.WithDebugLogger option API clients can set the VCR_DEBUG=true env var, which will configure a logger emitting events to os.Stderr.

Related to #108

cc: @marco-m , @akosyakov

@codecov-commenter

codecov-commenter commented Jun 22, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 71.32616% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.97%. Comparing base (fd3e9bc) to head (854bb3e).
⚠️ Report is 1 commits behind head on v4.

Files with missing lines Patch % Lines
pkg/cassette/cassette.go 46.00% 50 Missing and 4 partials ⚠️
pkg/recorder/recorder.go 87.42% 15 Missing and 7 partials ⚠️
pkg/recorder/middleware.go 0.00% 4 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pkg/cassette/cassette.go Outdated
Comment thread pkg/cassette/cassette.go Outdated
@dnaeon

dnaeon commented Jun 23, 2026

Copy link
Copy Markdown
Owner Author

@marco-m , a bunch of other places got debug events as well, please check them as well, thanks!

Comment thread pkg/recorder/recorder.go Outdated
Comment thread pkg/cassette/cassette.go Outdated
Comment thread pkg/recorder/recorder.go
@marco-m

marco-m commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Hello @dnaeon, I did a first pass. Is there anything specific you want another pair of eyes for ?

Comment thread pkg/cassette/cassette.go Outdated
Comment thread pkg/cassette/cassette.go
Comment thread pkg/cassette/cassette.go Outdated
Comment thread pkg/cassette/cassette.go Outdated
Comment thread pkg/recorder/middleware.go Outdated
@dnaeon

dnaeon commented Jun 23, 2026

Copy link
Copy Markdown
Owner Author

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

@marco-m

marco-m commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

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!

@marco-m marco-m left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, as usual it is a pleasure to interact with you @dnaeon :-)

@dnaeon dnaeon merged commit 2a9545b into v4 Jun 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants