mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 04:30:48 +00:00
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
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
/**
|
|
* @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();
|
|
};
|