feat(cli): migrate console calls to debugLogger and stdioHelpers (M3 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
This commit is contained in:
tanzhenxin 2026-01-26 15:02:37 +08:00
parent 45df0e8b82
commit 7995c65571
82 changed files with 606 additions and 485 deletions

View file

@ -29,7 +29,7 @@ import {
} from '../../utils/settingsUtils.js';
import { updateOutputLanguageFile } from '../../utils/languageUtils.js';
import { useVimMode } from '../contexts/VimModeContext.js';
import { type Config } from '@qwen-code/qwen-code-core';
import { createDebugLogger, type Config } from '@qwen-code/qwen-code-core';
import { useKeypress } from '../hooks/useKeypress.js';
import chalk from 'chalk';
import { cpSlice, cpLen, stripUnsafeCharacters } from '../utils/textUtils.js';
@ -46,6 +46,8 @@ interface SettingsDialogProps {
config?: Config;
}
const debugLogger = createDebugLogger('SETTINGS_DIALOG');
const maxItemsToShow = 8;
export function SettingsDialog({
@ -162,7 +164,7 @@ export function SettingsDialog({
{} as Settings,
);
console.log(
debugLogger.debug(
`[DEBUG SettingsDialog] Saving ${key} immediately with value:`,
newValue,
);
@ -177,7 +179,7 @@ export function SettingsDialog({
if (key === 'general.vimMode' && newValue !== vimEnabled) {
// Call toggleVimEnabled to sync the VimModeContext local state
toggleVimEnabled().catch((error) => {
console.error('Failed to toggle vim mode:', error);
debugLogger.error('Failed to toggle vim mode:', error);
});
}
@ -189,7 +191,7 @@ export function SettingsDialog({
try {
config?.setApprovalMode(settings.merged.tools.approvalMode);
} catch (error) {
console.error(
debugLogger.error(
'Failed to apply approval mode to current session:',
error,
);
@ -663,7 +665,7 @@ export function SettingsDialog({
try {
config?.setApprovalMode(settings.merged.tools.approvalMode);
} catch (error) {
console.error(
debugLogger.error(
'Failed to apply approval mode to current session:',
error,
);