mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-10 11:12:35 -07:00
add suppressConsoleOutput
This commit is contained in:
@@ -271,6 +271,7 @@ export async function main() {
|
||||
const isDebugMode = cliConfig.isDebugMode(argv);
|
||||
const consolePatcher = new ConsolePatcher({
|
||||
stderr: true,
|
||||
suppressConsoleOutput: true,
|
||||
debugMode: isDebugMode,
|
||||
onNewMessage: (msg) => {
|
||||
coreEvents.emitConsoleLog(msg.type, msg.content);
|
||||
|
||||
@@ -513,7 +513,7 @@ describe('runNonInteractive', () => {
|
||||
.mockReturnValueOnce(createStreamFromEvents(finalResponse));
|
||||
|
||||
await runNonInteractive({
|
||||
config: mockConfig,
|
||||
config: { ...mockConfig, getDebugMode: () => true } as Config,
|
||||
settings: mockSettings,
|
||||
input: 'Trigger tool error',
|
||||
prompt_id: 'prompt-id-3',
|
||||
@@ -608,7 +608,7 @@ describe('runNonInteractive', () => {
|
||||
.mockReturnValueOnce(createStreamFromEvents(finalResponse));
|
||||
|
||||
await runNonInteractive({
|
||||
config: mockConfig,
|
||||
config: { ...mockConfig, getDebugMode: () => true } as Config,
|
||||
settings: mockSettings,
|
||||
input: 'Trigger tool not found',
|
||||
prompt_id: 'prompt-id-5',
|
||||
|
||||
@@ -65,6 +65,7 @@ export async function runNonInteractive({
|
||||
return promptIdContext.run(prompt_id, async () => {
|
||||
const consolePatcher = new ConsolePatcher({
|
||||
stderr: true,
|
||||
suppressConsoleOutput: true,
|
||||
debugMode: config.getDebugMode(),
|
||||
onNewMessage: (msg) => {
|
||||
coreEvents.emitConsoleLog(msg.type, msg.content);
|
||||
|
||||
@@ -13,6 +13,7 @@ interface ConsolePatcherParams {
|
||||
onNewMessage?: (message: Omit<ConsoleMessageItem, 'id'>) => void;
|
||||
debugMode: boolean;
|
||||
stderr?: boolean;
|
||||
suppressConsoleOutput?: boolean;
|
||||
}
|
||||
|
||||
export class ConsolePatcher {
|
||||
@@ -49,6 +50,10 @@ export class ConsolePatcher {
|
||||
private patchConsoleMethod =
|
||||
(type: 'log' | 'warn' | 'error' | 'debug' | 'info') =>
|
||||
(...args: unknown[]) => {
|
||||
if (this.params.suppressConsoleOutput && !this.params.debugMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.params.stderr) {
|
||||
if (type !== 'debug' || this.params.debugMode) {
|
||||
this.originalConsoleError(this.formatArgs(args));
|
||||
|
||||
Reference in New Issue
Block a user