Skip to content

Switch Console.WriteLine over to Debug.WriteLine so as not to use Console.Out as debug log#111

Merged
gunpal5 merged 1 commit into
gunpal5:mainfrom
lassevk:main
Jul 22, 2026
Merged

Switch Console.WriteLine over to Debug.WriteLine so as not to use Console.Out as debug log#111
gunpal5 merged 1 commit into
gunpal5:mainfrom
lassevk:main

Conversation

@lassevk

@lassevk lassevk commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

The original code is using Console.Out for debug messages. I didn't want to outright strip them away, but they are noise in terms of using this library, especially if you're trying to write a CLI tool, like I am.

If the library requires a TextWriter to write debug messages to, either a different one should be used, or an optional override property should be provided so that users of the package can opt-out of this debug log.

Instead, I switched the offending lines to use Debug.WriteLine. If the lines have served their purpose, however, they should probably be removed instead.

I did not get to run all unit tests successfully, as it relied on locally installed npx, which I don't have, and I suspect the official list of models from Google has changed so that some of the tests that ensure models exists are also failing. I did not, however, find any tests related to using the offending debug log messages, so I assumed it was safe to make the switch.

Summary by CodeRabbit

  • Refactor
    • Improved diagnostic logging for streaming responses without displaying internal request and message details in standard application output.
    • Streaming activity and content information is now available through debug logging.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c8157a20-88d0-4dba-82ac-8e4be7821796

📥 Commits

Reviewing files that changed from the base of the PR and between 4aee127 and bfdfd23.

📒 Files selected for processing (1)
  • src/GenerativeAI.Microsoft/GenerativeAIChatClient.cs

📝 Walkthrough

Walkthrough

GetStreamingResponseAsync now sends stream and request-shape diagnostics to debug output rather than standard output, with System.Diagnostics imported to support Debug.WriteLine.

Changes

Streaming logging

Layer / File(s) Summary
Route streaming diagnostics to debug output
src/GenerativeAI.Microsoft/GenerativeAIChatClient.cs
The stream-start, per-content-type, and request Contents logs now use Debug.WriteLine instead of Console.WriteLine.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change from Console.WriteLine to Debug.WriteLine for debug logging.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@gunpal5
gunpal5 merged commit c37ff20 into gunpal5:main Jul 22, 2026
1 check 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.

2 participants