mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 05:00:46 +00:00
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:
parent
45df0e8b82
commit
7995c65571
82 changed files with 606 additions and 485 deletions
41
packages/cli/src/utils/stdioHelpers.ts
Normal file
41
packages/cli/src/utils/stdioHelpers.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright 2025 Qwen Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utility functions for writing to stdout/stderr in CLI commands.
|
||||
*
|
||||
* These helpers are used instead of console.log/console.error in standalone
|
||||
* CLI commands (like `qwen extensions list`) where the output IS the user-facing
|
||||
* result, not debug logging.
|
||||
*
|
||||
* For debug/diagnostic logging, use `createDebugLogger()` from @qwen-code/qwen-code-core.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Writes a message to stdout with a trailing newline.
|
||||
* Use for normal command output that the user expects to see.
|
||||
* Avoids double newlines if the message already ends with one.
|
||||
*/
|
||||
export const writeStdoutLine = (message: string): void => {
|
||||
process.stdout.write(message.endsWith('\n') ? message : `${message}\n`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes a message to stderr with a trailing newline.
|
||||
* Use for error messages in CLI commands.
|
||||
* Avoids double newlines if the message already ends with one.
|
||||
*/
|
||||
export const writeStderrLine = (message: string): void => {
|
||||
process.stderr.write(message.endsWith('\n') ? message : `${message}\n`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the terminal screen.
|
||||
* Use instead of console.clear() to satisfy no-console lint rules.
|
||||
*/
|
||||
export const clearScreen = (): void => {
|
||||
console.clear();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue