Skip to content

fix: don't output overly verbose watermill trace logs by default#547

Merged
laouji merged 1 commit into
mainfrom
fix/reduce-debug-logs
Feb 5, 2026
Merged

fix: don't output overly verbose watermill trace logs by default#547
laouji merged 1 commit into
mainfrom
fix/reduce-debug-logs

Conversation

@laouji
Copy link
Copy Markdown
Contributor

@laouji laouji commented Feb 5, 2026

Watermill consumers output extremely verbose trace logs. Our logging.Logger doesn't have a trace mode, but outputs trace logs as part of the Debug mode.

This gives us the option to still see debug logs and omit the more verbose trace logs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 5, 2026

Walkthrough

The PR introduces mock code generation for the Logger interface via mockgen and extends WatermillLoggerAdapter with a trace logging flag to conditionally include trace-level logs based on runtime configuration.

Changes

Cohort / File(s) Summary
Mock Generation
logging/logging.go, logging/logging_generated.go
Added go:generate directive to produce mockgen implementation. Generated file provides MockLogger type and MockLoggerMockRecorder with mocked methods for all Logger interface operations (Debug, Debugf, Error, Errorf, Info, Infof, Writer, WithContext, WithField, WithFields).
Trace Logging Control
publish/logging.go, publish/logging_test.go
Modified NewWatermillLoggerAdapter constructor to accept a trace boolean parameter controlling whether Trace method outputs logs. Added includeTraceLogs field to watermillLoggerAdapter struct and implemented conditional logging in Trace method. Includes comprehensive tests verifying Error, Info, Debug, and Trace behavior with tracing enabled and disabled.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A mock for the logger now hops,
With trace logs that start and stop,
Generated with care, flags held fair,
Tests verify all the affair! 🔍✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main change: reducing verbose watermill trace logs by default, which aligns perfectly with the actual changeset modifications.
Description check ✅ Passed The description accurately explains the context and rationale for the changes, relating to the verbose trace logs issue and the need to decouple debug and trace logging.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/reduce-debug-logs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@laouji laouji changed the title Fix: don't output overly verbose watermill trace logs by default fix: don't output overly verbose watermill trace logs by default Feb 5, 2026
@laouji laouji force-pushed the fix/reduce-debug-logs branch from d9b6e6c to 34a0899 Compare February 5, 2026 13:28
@laouji laouji marked this pull request as ready for review February 5, 2026 13:28
@laouji laouji requested a review from a team as a code owner February 5, 2026 13:28
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
publish/logging.go (1)

35-38: ⚠️ Potential issue | 🟠 Major

Trace flag is lost when With(...) is used.

With(...) returns a new adapter without copying includeTraceLogs, so trace gets silently disabled on derived loggers. Propagate the flag when creating the new adapter.

🛠️ Proposed fix
 func (w watermillLoggerAdapter) With(fields watermill.LogFields) watermill.LoggerAdapter {
 	return watermillLoggerAdapter{
+		includeTraceLogs: w.includeTraceLogs,
 		Logger: w.Logger.WithFields(fields),
 	}
 }
🤖 Fix all issues with AI agents
In `@publish/logging.go`:
- Around line 41-45: The public API was changed; restore the original
NewWatermillLoggerAdapter(logger logging.Logger) signature as a compatibility
wrapper and introduce a new constructor that accepts the trace flag. Rename the
existing NewWatermillLoggerAdapter(logger logging.Logger, trace bool)
implementation to NewWatermillLoggerAdapterWithTrace(logger logging.Logger,
trace bool) (or similar), then add a simple NewWatermillLoggerAdapter(logger
logging.Logger) that returns NewWatermillLoggerAdapterWithTrace(logger, false);
update references if needed so callers default to trace=false unless they call
the new WithTrace constructor.

Comment thread publish/logging.go
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 5.00000% with 95 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.80%. Comparing base (df80fb3) to head (34a0899).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
logging/logging_generated.go 0.00% 95 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #547      +/-   ##
==========================================
- Coverage   29.13%   28.80%   -0.33%     
==========================================
  Files         174      175       +1     
  Lines        6965     7062      +97     
==========================================
+ Hits         2029     2034       +5     
- Misses       4819     4911      +92     
  Partials      117      117              

☔ View full report in Codecov by Sentry.
📢 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.

@laouji laouji added this pull request to the merge queue Feb 5, 2026
Merged via the queue into main with commit 8d136e6 Feb 5, 2026
5 of 7 checks passed
@laouji laouji deleted the fix/reduce-debug-logs branch February 5, 2026 14:01
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.

2 participants