feat: debug mode output refactor — route console calls to logfile-first debugLogger - #1610
Merged
Conversation
Implement debug logfile foundation for routing internal diagnostics to a per-session log file instead of polluting the terminal. Core changes: - Add DebugLogger interface and createDebugLogger() in debugLogger.ts - Add Storage.getGlobalDebugDir() and getDebugLogPath() for log paths - Add Config.getDebugLogger() method with session-scoped logger - Track write failures via isDebugLoggingDegraded() CLI changes: - Add DebugModeNotification component for interactive startup notice - Add non-interactive debug notice to stderr in gemini.tsx Log files are written to ~/.qwen/debug/<sessionId>.txt with format: 2026-01-24T10:30:00.000Z [LEVEL] [TAG] message Debug logging is always-on; debug mode only controls the startup notice.
Phase 4 - Extension/OAuth infrastructure: - qwenOAuth2.ts, sharedTokenManager.ts, qwenContentGenerator.ts - extensionManager.ts, github.ts, claude-converter.ts - gemini-converter.ts, extensionSettings.ts Phase 5 - MCP subsystem: - mcp-client.ts, oauth-provider.ts, oauth-utils.ts - oauth-token-storage.ts, keychain-token-storage.ts - google-auth-provider.ts, sa-impersonation-provider.ts - mcp-client-manager.ts, sdk-control-client-transport.ts Also updates related test files to mock debugLogger.
Migrate remaining console.* calls in packages/core utilities and services to use the structured DebugLogger pattern. This continues the Phase 6 migration work for utilities and helpers. Files migrated: - config/config.ts, core/client.ts, core/prompts.ts - core/anthropicContentGenerator, core/openaiContentGenerator - core/coreToolScheduler.ts, fallback/handler.ts - models/modelRegistry.ts, prompts/prompt-registry.ts - services/chatRecordingService.ts, sessionService.ts, loopDetectionService.ts - skills/skill-load.ts, skill-manager.ts - subagents/subagent.ts, subagent-manager.ts - utils: editor, environmentContext, fileUtils, getFolderStructure, installationManager, jsonl-utils, llm-edit-fixer, nextSpeakerChecker, openaiLogger, request-tokenizer/*, retry, ripgrepUtils, safeJsonParse, summarizer, systemEncoding, workspaceContext Remaining: utils/errorReporting.ts (13 calls)
…Phase 7-9) Route CLI console.* calls to structured logging: - Debug/internal diagnostics → debugLogger (logfile) - User-facing output → writeStdoutLine/writeStderrLine/clearScreen (stdioHelpers) - Add stdioHelpers.ts with writeStdoutLine, writeStderrLine, clearScreen - Migrate pre-session files (gemini.tsx, sandbox.ts, config.ts) to stdioHelpers - Migrate extension/MCP commands to stdioHelpers - Migrate non-interactive session/control to debugLogger - Migrate UI hooks and components to debugLogger
Contributor
📋 Review SummaryThis PR implements a comprehensive debug logging refactor that routes all 🔍 General Feedback
🎯 Specific Feedback🔴 CriticalNo specific issues identified in this review. 🟡 HighNo specific issues identified in this review. 🟢 Medium
🔵 Low
✅ Highlights
|
Contributor
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
Improve ACP JSON-RPC diagnostics by logging parse failures, request errors, and response errors to aid debugging.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
…rror reporting - Replace ConsolePatcher with centralized debugLogger utility - Refactor errorReporting to use debugLogger instead of file-based reporting - Remove user-facing console message components: - Delete ConsolePatcher.ts, useConsoleMessages.ts/hook - Delete ConsoleSummaryDisplay.tsx, DetailedMessagesDisplay.tsx - Update all tests in packages/core and packages/cli: - Mock debugLogger where needed - Remove assertions for console output on non-critical errors - Keep debugLogger assertions for fatal/network errors - Use HOME directory mocking for hermetic file system tests Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Replace console.log/warn/error with debugLogger in LspServerManager.ts - Replace console.log/warn/error with debugLogger in NativeLspService.ts - Use [LSP] tag for all LSP-related debug output - Completes Phase 11 of debug logging refactor Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- LspConfigLoader.ts: 7 console.warn calls → debugLogger.warn - LspConnectionFactory.ts: 1 console.warn call → debugLogger.warn - Add eslint no-console overrides for test files and scripts - Completes LSP subsystem migration (8 more calls) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Add 'no-console': 'error' to main source files (packages/core/src, packages/cli/src) - Configure targeted allowlist for: - Test files and scripts - VS Code extension (out of scope) - WebUI package (UI component library) - Integration tests - Intentionally excluded files (acpAgent.ts, stdioHelpers.ts) - Consolidate no-console overrides into a single clearly-marked section - Enforced in CI via npm run lint:ci Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- Remove verbose tool execution debug logs to reduce noise - Add debug logging for config initialization phases - Add comprehensive debug logging for skill loading/management - Add rate limiting for QwenLogger network error logs - Remove Notifications component from DefaultAppLayout - Update tests to reflect UI changes and logging behavior Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
tanzhenxin
marked this pull request as ready for review
February 5, 2026 03:39
tanzhenxin
requested review from
DennisYu07,
LaZzyMan,
Mingholy,
gwinthis and
pomelo-nwu
as code owners
February 5, 2026 03:39
pomelo-nwu
approved these changes
Feb 5, 2026
pomelo-nwu
left a comment
Collaborator
There was a problem hiding this comment.
The rubber stamp is ready!
xaelistic
pushed a commit
to xaelistic/qwen-code
that referenced
this pull request
Jun 7, 2026
feat: debug mode output refactor — route console calls to logfile-first debugLogger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Route all
console.*calls in CLI and Core runtime code to structured logging, so the terminal UI stays clean while diagnostics are always captured to a per-session logfile at~/.qwen/debug/<sessionId>.txt.Dive Deeper
Problem
Qwen Code mixes internal diagnostics (
console.debug,console.warn,console.error) into user-facing terminal output. Debug info is lost when debug mode is off, and noisy when it's on.Solution
Logfile-first architecture — a per-session debug logfile is always written, regardless of debug mode. All runtime
console.*calls are replaced with one of:debugLogger— internal diagnostics routed to the logfile viacreateDebugLogger('TAG')orconfig.getDebugLogger()writeStdoutLine/writeStderrLine/clearScreen— user-facing CLI output routed to stdout/stderr via helpers incli/utils/stdioHelpers.tsDebug mode only controls whether a startup notice is shown to the user.
Routing rules
debugLogger.debug/info/warn/error(...)→ logfilewriteStdoutLine/writeStderrLine→ stdout/stderrdebugLoggeror removeWhat this PR includes
DebugLoggerinterface,createDebugLogger(),Storage.getDebugLogPath(),Config.getDebugLogger(), degraded-logging detectionDebugModeNotificationcomponent (interactive) + stderr notice (non-interactive) when debug mode is ondebugLoggerdebugLoggerorstdioHelpersstdioHelpers.tswriteStdoutLine,writeStderrLine,clearScreenfor lint-safe user-facing outputFiles NOT migrated
core/utils/errorReporting.tscli/ui/utils/ConsolePatcher.tscli/acp-integration/acpAgent.tsconsole.*reassignment for ACP modeStill in progress
console.*callsno-consoleenforcement with scoped allowlistReviewer Test Plan
--debug— verify startup notice shows logfile path; check~/.qwen/debug/<sessionId>.txtis written with<timestamp> [LEVEL] [TAG] messageformatecho "hello" | qwen -p "say hi") — verify clean stdout; verify--debugprints notice to stderrqwen extensions list,qwen mcp list) — verify user-facing output still worksTesting Matrix
Linked issues / bugs