Skip to content

fix: remove console.info statements that pollute stdout#541

Open
reneaaron wants to merge 1 commit intomasterfrom
fix/remove-console-info
Open

fix: remove console.info statements that pollute stdout#541
reneaaron wants to merge 1 commit intomasterfrom
fix/remove-console-info

Conversation

@reneaaron
Copy link
Copy Markdown
Member

@reneaaron reneaaron commented Apr 7, 2026

Summary

  • Remove all console.info calls across NWAClient, NWCClient, NWCWalletService, and OauthWeblnProvider
  • Agents and tools consuming the SDK (e.g. via lightning-tools) were seeing log lines mixed into stdout, which could break parsing

Test plan

  • Verify SDK no longer logs to stdout during normal operation
  • Run existing tests to confirm no regressions

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated logging configuration to adjust console output levels across the application for improved diagnostic output.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

ESLint configuration was updated to permit console.debug statements instead of console.info. Corresponding logging statements across NWC and WebLN modules were downgraded from console.info to console.debug to align with the updated rule configuration.

Changes

Cohort / File(s) Summary
ESLint Configuration
.eslintrc.json
Updated no-console rule allowlist to permit console.debug in place of console.info.
NWC Module Logging
src/nwc/NWAClient.ts, src/nwc/NWCClient.ts, src/nwc/NWCWalletService.ts
Downgraded relay subscription lifecycle logging statements from console.info to console.debug across relay connection callbacks and subscription confirmations.
WebLN Module Logging
src/webln/OauthWeblnProvider.ts
Changed OAuth processing log statement from console.info to console.debug.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Console logs softly hop away,
From info's brightness to debug's gray,
ESLint nods with rules refined,
Leaving noisy logs behind!
Silence blooms where chatter dwelled—
A rabbit's log tale, gently quelled. 🌙

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: remove console.info statements that pollute stdout' directly matches the main objective: replacing console.info with console.debug across multiple files to prevent log pollution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/remove-console-info

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.

@rolznz
Copy link
Copy Markdown
Member

rolznz commented Apr 7, 2026

Linking to #231 - rather than removing them completely, I like the idea of a verbose mode (and do we need to check debug, etc level logs too?). What do you think?

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>
@reneaaron reneaaron force-pushed the fix/remove-console-info branch from 1c6a38d to 454e97f Compare April 7, 2026 21:28
@reneaaron
Copy link
Copy Markdown
Member Author

This is a first step to address stdout pollution — switching console.info to console.debug so the SDK stays silent on stdout by default.

As a follow-up, we should plan how proper log-level support could work for this library (e.g. a debug option, the debug npm package, or a pluggable logger interface) so that consumers can opt into debug/info/warn output when needed.

@reneaaron reneaaron marked this pull request as ready for review April 9, 2026 08:32
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.eslintrc.json:
- Line 24: The ESLint rule currently allows console.debug via "no-console":
["error", { "allow": ["debug", "warn", "error"] }], but console.debug still
writes to stdout in Node and violates the "no stdout pollution" goal; update the
lint config to remove "debug" from the allowed list and instead route
debug-level logging through a dedicated logger interface (e.g., replace usages
of console.debug with a Logger.debug call or a noop default logger), so keep
"warn" and "error" allowed but ensure all debug output uses the new logger
rather than console.debug.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 561eae9a-7025-416e-8c0c-27bdd6ebd274

📥 Commits

Reviewing files that changed from the base of the PR and between 08a6cd7 and 454e97f.

📒 Files selected for processing (5)
  • .eslintrc.json
  • src/nwc/NWAClient.ts
  • src/nwc/NWCClient.ts
  • src/nwc/NWCWalletService.ts
  • src/webln/OauthWeblnProvider.ts

],
"@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }],
"no-console": ["error", { "allow": ["info", "warn", "error"] }],
"no-console": ["error", { "allow": ["debug", "warn", "error"] }],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In current Node.js documentation, does console.debug()write to stdout or stderr, and is it an alias ofconsole.log()?

💡 Result:

In the current Node.js docs, console.debug() is an alias of console.log() [1]. Since console.log() prints to stdout, console.debug() also writes to stdout (not stderr) [2].

Sources: [1] [2]


console.debug writes to stdout and will still violate the "no stdout pollution" goal.

Allowing console.debug in this config still emits to stdout in Node.js (it's an alias of console.log), which keeps the original parsing risk in place.

Suggested fix
-    "no-console": ["error", { "allow": ["debug", "warn", "error"] }],
+    "no-console": ["error", { "allow": ["warn", "error"] }],

Route debug logs through an explicit logger interface (noop by default, opt-in by consumers).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"no-console": ["error", { "allow": ["debug", "warn", "error"] }],
"no-console": ["error", { "allow": ["warn", "error"] }],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.eslintrc.json at line 24, The ESLint rule currently allows console.debug
via "no-console": ["error", { "allow": ["debug", "warn", "error"] }], but
console.debug still writes to stdout in Node and violates the "no stdout
pollution" goal; update the lint config to remove "debug" from the allowed list
and instead route debug-level logging through a dedicated logger interface
(e.g., replace usages of console.debug with a Logger.debug call or a noop
default logger), so keep "warn" and "error" allowed but ensure all debug output
uses the new logger rather than console.debug.

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