mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 11:04:42 -07:00
refactor(logging): Centralize console logging with debugLogger (#11590)
This commit is contained in:
@@ -9,6 +9,7 @@ import * as path from 'node:path';
|
||||
import type { PartListUnion, PartUnion } from '@google/genai';
|
||||
import type { AnyToolInvocation, Config } from '@google/gemini-cli-core';
|
||||
import {
|
||||
debugLogger,
|
||||
getErrorMessage,
|
||||
isNodeError,
|
||||
unescapePath,
|
||||
@@ -372,7 +373,7 @@ export async function handleAtCommand({
|
||||
}
|
||||
|
||||
const message = `Ignored ${totalIgnored} files:\n${messages.join('\n')}`;
|
||||
console.log(message);
|
||||
debugLogger.log(message);
|
||||
onDebugMessage(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -222,8 +222,6 @@ export const useShellCommandProcessor = (
|
||||
shellExecutionConfig,
|
||||
);
|
||||
|
||||
console.log(terminalHeight, terminalWidth);
|
||||
|
||||
executionPid = pid;
|
||||
if (pid) {
|
||||
setActiveShellPtyId(pid);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { debugLogger } from '@google/gemini-cli-core';
|
||||
import { useState, useCallback } from 'react';
|
||||
|
||||
interface Logger {
|
||||
@@ -69,7 +70,10 @@ export function useInputHistoryStore(): UseInputHistoryStoreReturn {
|
||||
setIsInitialized(true);
|
||||
} catch (error) {
|
||||
// Start with empty history even if logger initialization fails
|
||||
console.warn('Failed to initialize input history from logger:', error);
|
||||
debugLogger.warn(
|
||||
'Failed to initialize input history from logger:',
|
||||
error,
|
||||
);
|
||||
setPastSessionMessages([]);
|
||||
recalculateHistory([], []);
|
||||
setIsInitialized(true);
|
||||
|
||||
@@ -20,7 +20,7 @@ import type {
|
||||
Status as CoreStatus,
|
||||
EditorType,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { CoreToolScheduler } from '@google/gemini-cli-core';
|
||||
import { CoreToolScheduler, debugLogger } from '@google/gemini-cli-core';
|
||||
import { useCallback, useState, useMemo } from 'react';
|
||||
import type {
|
||||
HistoryItemToolGroup,
|
||||
@@ -198,7 +198,7 @@ function mapCoreStatusToDisplayStatus(coreStatus: CoreStatus): ToolCallStatus {
|
||||
return ToolCallStatus.Pending;
|
||||
default: {
|
||||
const exhaustiveCheck: never = coreStatus;
|
||||
console.warn(`Unknown core status encountered: ${exhaustiveCheck}`);
|
||||
debugLogger.warn(`Unknown core status encountered: ${exhaustiveCheck}`);
|
||||
return ToolCallStatus.Error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import type { Message } from '../types.js';
|
||||
import { MessageType } from '../types.js';
|
||||
import type { Config } from '@google/gemini-cli-core';
|
||||
import { debugLogger, type Config } from '@google/gemini-cli-core';
|
||||
import type { LoadedSettings } from '../../config/settings.js';
|
||||
|
||||
export function createShowMemoryAction(
|
||||
@@ -27,7 +27,7 @@ export function createShowMemoryAction(
|
||||
const debugMode = config.getDebugMode();
|
||||
|
||||
if (debugMode) {
|
||||
console.log('[DEBUG] Show Memory command invoked.');
|
||||
debugLogger.log('[DEBUG] Show Memory command invoked.');
|
||||
}
|
||||
|
||||
const currentMemory = config.getUserMemory();
|
||||
@@ -38,10 +38,10 @@ export function createShowMemoryAction(
|
||||
: [contextFileName];
|
||||
|
||||
if (debugMode) {
|
||||
console.log(
|
||||
debugLogger.log(
|
||||
`[DEBUG] Showing memory. Content from config.getUserMemory() (first 200 chars): ${currentMemory.substring(0, 200)}...`,
|
||||
);
|
||||
console.log(`[DEBUG] Number of context files loaded: ${fileCount}`);
|
||||
debugLogger.log(`[DEBUG] Number of context files loaded: ${fileCount}`);
|
||||
}
|
||||
|
||||
if (fileCount > 0) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
type CommandContext,
|
||||
type SlashCommand,
|
||||
} from '../commands/types.js';
|
||||
import { debugLogger } from '@google/gemini-cli-core';
|
||||
|
||||
// Type alias for improved type safety based on actual fzf result structure
|
||||
type FzfCommandResult = {
|
||||
@@ -189,7 +190,7 @@ function useCommandSuggestions(
|
||||
|
||||
// Safety check: ensure leafCommand and completion exist
|
||||
if (!leafCommand?.completion) {
|
||||
console.warn(
|
||||
debugLogger.warn(
|
||||
'Attempted argument completion without completion function',
|
||||
);
|
||||
return;
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useCallback, useReducer, useEffect } from 'react';
|
||||
import type { Key } from './useKeypress.js';
|
||||
import type { TextBuffer } from '../components/shared/text-buffer.js';
|
||||
import { useVimMode } from '../contexts/VimModeContext.js';
|
||||
import { debugLogger } from '@google/gemini-cli-core';
|
||||
|
||||
export type VimMode = 'NORMAL' | 'INSERT';
|
||||
|
||||
@@ -394,7 +395,7 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) {
|
||||
normalizedKey = normalizeKey(key);
|
||||
} catch (error) {
|
||||
// Handle malformed key inputs gracefully
|
||||
console.warn('Malformed key input in vim mode:', key, error);
|
||||
debugLogger.warn('Malformed key input in vim mode:', key, error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user