feat: replace console.debug with injectable logger interface#542
feat: replace console.debug with injectable logger interface#542
Conversation
console.info writes to stdout, which pollutes output for agents and tools consuming the SDK. console.debug writes to stderr instead. Also update eslint no-console rule to disallow console.info going forward. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove console.debug from the ESLint allow list and introduce a Logger
interface with a noop default. All debug output now routes through
this.logger.debug(), keeping stdout clean by default while letting
consumers opt in via { logger: console } or a custom logger.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/nwc/NWAClient.ts (1)
31-55:⚠️ Potential issue | 🟡 MinorPropagate injected logger to internally created
NWCClient.
NWAClientaccepts logger injection (Lines 31, 55), but thenew NWCClient(...)created in the subscribe flow does not receive it (Line 198), so downstream client debug logs remain disabled.Suggested patch
const client = new NWCClient({ relayUrls: this.options.relayUrls, secret: this.appSecretKey, walletPubkey: event.pubkey, + logger: this.logger, });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/nwc/NWAClient.ts` around lines 31 - 55, The NWAClient accepts an injected logger (this.logger / options.logger) but does not pass it into the internally created NWCClient in the subscribe flow (where new NWCClient(...) is constructed), so downstream logs stay disabled; update the code that constructs NWCClient to pass this.logger (or options.logger || noopLogger) into NWCClient's constructor or options so the inner client receives the same logger, ensuring you reference the NWAClient constructor/this.logger and the place where new NWCClient(...) is created (subscribe flow) when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/nwc/NWAClient.ts`:
- Around line 31-55: The NWAClient accepts an injected logger (this.logger /
options.logger) but does not pass it into the internally created NWCClient in
the subscribe flow (where new NWCClient(...) is constructed), so downstream logs
stay disabled; update the code that constructs NWCClient to pass this.logger (or
options.logger || noopLogger) into NWCClient's constructor or options so the
inner client receives the same logger, ensuring you reference the NWAClient
constructor/this.logger and the place where new NWCClient(...) is created
(subscribe flow) when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: dce1ebad-63c4-4284-aaec-8a14a3cb1c03
📒 Files selected for processing (7)
.eslintrc.jsonsrc/index.tssrc/logger.tssrc/nwc/NWAClient.tssrc/nwc/NWCClient.tssrc/nwc/NWCWalletService.tssrc/webln/OauthWeblnProvider.ts
The NWCClient created inside the subscribe flow was not receiving the injected logger, so downstream debug logs stayed silenced even when a logger was provided. Pass this.logger through. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Loggerinterface (src/logger.ts) with a noop default, exported from the package root"debug"from the ESLintno-consoleallow list soconsole.debugis now a lint errorloggertoNWCClient,NWAClient,NWCWalletService, andOauthWeblnProvideroptions — defaults to silent noop, consumers can pass{ logger: console }to opt inconsole.debuglinesTest plan
yarn test){ logger: console }to confirm debug output appears🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Loggerinterface for custom logging configuration. Logger can now be optionally injected into NWA, NWC, and OAuth clients for flexible debug output control.Chores