mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 20:20:57 +00:00
feat(core,cli): add debug logging infrastructure (M0-M2)
Implement debug logfile foundation for routing internal diagnostics to a per-session log file instead of polluting the terminal. Core changes: - Add DebugLogger interface and createDebugLogger() in debugLogger.ts - Add Storage.getGlobalDebugDir() and getDebugLogPath() for log paths - Add Config.getDebugLogger() method with session-scoped logger - Track write failures via isDebugLoggingDegraded() CLI changes: - Add DebugModeNotification component for interactive startup notice - Add non-interactive debug notice to stderr in gemini.tsx Log files are written to ~/.qwen/debug/<sessionId>.txt with format: 2026-01-24T10:30:00.000Z [LEVEL] [TAG] message Debug logging is always-on; debug mode only controls the startup notice.
This commit is contained in:
parent
829ba9c431
commit
ba2824b0b0
8 changed files with 409 additions and 6 deletions
36
packages/cli/src/ui/components/DebugModeNotification.tsx
Normal file
36
packages/cli/src/ui/components/DebugModeNotification.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { Box, Text } from 'ink';
|
||||
import { Storage, isDebugLoggingDegraded } from '@qwen-code/qwen-code-core';
|
||||
import { useConfig } from '../contexts/ConfigContext.js';
|
||||
import { theme } from '../semantic-colors.js';
|
||||
|
||||
/**
|
||||
* Displays debug mode status and log file path when debug mode is enabled.
|
||||
*/
|
||||
export const DebugModeNotification = () => {
|
||||
const config = useConfig();
|
||||
|
||||
if (!config.getDebugMode()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const logPath = Storage.getDebugLogPath(config.getSessionId());
|
||||
const isDegraded = isDebugLoggingDegraded();
|
||||
|
||||
return (
|
||||
<Box paddingX={1} marginTop={1} flexDirection="column">
|
||||
<Text color={theme.status.warning}>Debug mode enabled</Text>
|
||||
<Text dimColor>Logging to: {logPath}</Text>
|
||||
{isDegraded && (
|
||||
<Text dimColor>
|
||||
Warning: Debug logging is degraded (write failures occurred)
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
|
@ -9,6 +9,7 @@ import { useAppContext } from '../contexts/AppContext.js';
|
|||
import { useUIState } from '../contexts/UIStateContext.js';
|
||||
import { theme } from '../semantic-colors.js';
|
||||
import { StreamingState } from '../types.js';
|
||||
import { DebugModeNotification } from './DebugModeNotification.js';
|
||||
import { UpdateNotification } from './UpdateNotification.js';
|
||||
|
||||
export const Notifications = () => {
|
||||
|
|
@ -19,13 +20,10 @@ export const Notifications = () => {
|
|||
const showInitError =
|
||||
initError && streamingState !== StreamingState.Responding;
|
||||
|
||||
if (!showStartupWarnings && !showInitError && !updateInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{updateInfo && <UpdateNotification message={updateInfo.message} />}
|
||||
<DebugModeNotification />
|
||||
{showStartupWarnings && (
|
||||
<Box
|
||||
borderStyle="round"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue