diff --git a/packages/cli/src/ui/AppContainer.tsx b/packages/cli/src/ui/AppContainer.tsx index 426543d772..ae0f43b418 100644 --- a/packages/cli/src/ui/AppContainer.tsx +++ b/packages/cli/src/ui/AppContainer.tsx @@ -590,7 +590,7 @@ Logging in with Google... Please restart Gemini CLI to continue. }, Date.now(), ); - console.error('Error refreshing memory:', error); + debugLogger.warn('Error refreshing memory:', error); } }, [config, historyManager, settings.merged]); diff --git a/packages/core/src/tools/glob.ts b/packages/core/src/tools/glob.ts index 0dbd71e479..f090056654 100644 --- a/packages/core/src/tools/glob.ts +++ b/packages/core/src/tools/glob.ts @@ -15,6 +15,8 @@ import { type Config } from '../config/config.js'; import { DEFAULT_FILE_FILTERING_OPTIONS } from '../config/constants.js'; import { ToolErrorType } from './tool-error.js'; import { GLOB_TOOL_NAME } from './tool-names.js'; +import { getErrorMessage } from '../utils/errors.js'; +import { debugLogger } from '../utils/debugLogger.js'; // Subset of 'Path' interface provided by 'glob' that we can implement for testing export interface GlobPath { @@ -238,9 +240,8 @@ class GlobToolInvocation extends BaseToolInvocation< returnDisplay: `Found ${fileCount} matching file(s)`, }; } catch (error) { - const errorMessage = - error instanceof Error ? error.message : String(error); - console.error(`GlobLogic execute Error: ${errorMessage}`, error); + debugLogger.warn(`GlobLogic execute Error`, error); + const errorMessage = getErrorMessage(error); const rawError = `Error during glob search operation: ${errorMessage}`; return { llmContent: rawError, diff --git a/packages/core/src/tools/grep.ts b/packages/core/src/tools/grep.ts index e2637accb8..d279d65e49 100644 --- a/packages/core/src/tools/grep.ts +++ b/packages/core/src/tools/grep.ts @@ -199,7 +199,7 @@ class GrepToolInvocation extends BaseToolInvocation< returnDisplay: `Found ${matchCount} ${matchTerm}`, }; } catch (error) { - console.error(`Error during GrepLogic execution: ${error}`); + debugLogger.warn(`Error during GrepLogic execution: ${error}`); const errorMessage = getErrorMessage(error); return { llmContent: `Error during grep search operation: ${errorMessage}`, @@ -552,7 +552,7 @@ class GrepToolInvocation extends BaseToolInvocation< return allMatches; } catch (error: unknown) { - console.error( + debugLogger.warn( `GrepLogic: Error in performGrepSearch (Strategy: ${strategyUsed}): ${getErrorMessage( error, )}`, diff --git a/packages/core/src/tools/ls.test.ts b/packages/core/src/tools/ls.test.ts index 1cda0c9e7e..d6c828c94b 100644 --- a/packages/core/src/tools/ls.test.ts +++ b/packages/core/src/tools/ls.test.ts @@ -248,11 +248,6 @@ describe('LSTool', () => { return originalStat(p); }); - // Spy on console.error to verify it's called - const consoleErrorSpy = vi - .spyOn(console, 'error') - .mockImplementation(() => {}); - const invocation = lsTool.build({ path: tempRootDir }); const result = await invocation.execute(abortSignal); @@ -261,13 +256,7 @@ describe('LSTool', () => { expect(result.llmContent).not.toContain('problematic.txt'); expect(result.returnDisplay).toBe('Listed 1 item(s).'); - // Verify error was logged - expect(consoleErrorSpy).toHaveBeenCalledWith( - expect.stringMatching(/Error accessing.*problematic\.txt/s), - ); - statSpy.mockRestore(); - consoleErrorSpy.mockRestore(); }); }); diff --git a/packages/core/src/tools/ls.ts b/packages/core/src/tools/ls.ts index 7aac367e50..b899ae8fcc 100644 --- a/packages/core/src/tools/ls.ts +++ b/packages/core/src/tools/ls.ts @@ -14,6 +14,7 @@ import type { Config } from '../config/config.js'; import { DEFAULT_FILE_FILTERING_OPTIONS } from '../config/constants.js'; import { ToolErrorType } from './tool-error.js'; import { LS_TOOL_NAME } from './tool-names.js'; +import { debugLogger } from '../utils/debugLogger.js'; /** * Parameters for the LS tool @@ -205,7 +206,7 @@ class LSToolInvocation extends BaseToolInvocation { }); } catch (error) { // Log error internally but don't fail the whole listing - console.error(`Error accessing ${fullPath}: ${error}`); + debugLogger.debug(`Error accessing ${fullPath}: ${error}`); } }