update log text
This commit is contained in:
parent
eba9fa9782
commit
3fc21b920e
@ -57,7 +57,7 @@ export class CustomActions {
|
||||
}
|
||||
} catch (error) {
|
||||
// Show error message
|
||||
logger.channel()?.error(`Failed to parse actions: ${error}`);
|
||||
logger.channel()?.error(`Failed to parse actions due to error: ${error}`);
|
||||
logger.channel()?.show();
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class CustomCommands {
|
||||
}
|
||||
} catch (error) {
|
||||
// 显示错误消息
|
||||
logger.channel()?.error(`Failed to parse commands: ${error}`);
|
||||
logger.channel()?.error(`Failed to parse commands due to error: ${error}`);
|
||||
logger.channel()?.show();
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ class CustomCommands {
|
||||
commandMessage = commandMessage.replace(`$${i + 1}`, userInputArray[i]);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.channel()?.error(`Failed to parse user input: ${userInput} error: ${error}`);
|
||||
logger.channel()?.error(`Failed to parse user input '${userInput}' due to error: ${error}. A valid input should be in the format: ['aa', 'bb']`);
|
||||
logger.channel()?.show();
|
||||
return '';
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ export const customCommandContext: ChatContext = {
|
||||
const tempDir = await createTempSubdirectory('devchat/context');
|
||||
const diffFile = path.join(tempDir, 'custom.txt');
|
||||
|
||||
logger.channel()?.info(`custom command: ${customCommand}`);
|
||||
logger.channel()?.info(`Your custom command is: ${customCommand}`);
|
||||
const result = await runCommandStringAndWriteOutput(customCommand, diffFile);
|
||||
logger.channel()?.info(`custom command: ${customCommand} exit code:`, result.exitCode);
|
||||
logger.channel()?.info(` exit code:`, result.exitCode);
|
||||
|
||||
logger.channel()?.debug(`custom command: ${customCommand} stdout:`, result.stdout);
|
||||
logger.channel()?.debug(`custom command: ${customCommand} stderr:`, result.stderr);
|
||||
logger.channel()?.debug(` stdout:`, result.stdout);
|
||||
logger.channel()?.debug(` stderr:`, result.stderr);
|
||||
return `[context|${diffFile}]`;
|
||||
}
|
||||
return '';
|
||||
|
@ -10,14 +10,14 @@ export const gitDiffContext: ChatContext = {
|
||||
description: 'diff for all changes',
|
||||
handler: async () => {
|
||||
const tempDir = await createTempSubdirectory('devchat/context');
|
||||
const diff_file = path.join(tempDir, 'diff_all.txt');
|
||||
const diffFile = path.join(tempDir, 'diff_all.txt');
|
||||
|
||||
logger.channel()?.info(`git diff`);
|
||||
const result = await runCommandStringAndWriteOutput('git diff HEAD', diff_file);
|
||||
logger.channel()?.info(`git diff exit code:`, result.exitCode);
|
||||
logger.channel()?.info(`git diff HEAD:`);
|
||||
const result = await runCommandStringAndWriteOutput('git diff HEAD', diffFile);
|
||||
logger.channel()?.info(` exit code:`, result.exitCode);
|
||||
|
||||
logger.channel()?.debug(`git diff stdout:`, result.stdout);
|
||||
logger.channel()?.debug(`git diff stderr:`, result.stderr);
|
||||
return `[context|${diff_file}]`;
|
||||
logger.channel()?.debug(` stdout:`, result.stdout);
|
||||
logger.channel()?.debug(` stderr:`, result.stderr);
|
||||
return `[context|${diffFile}]`;
|
||||
},
|
||||
};
|
||||
|
@ -10,14 +10,14 @@ export const gitDiffCachedContext: ChatContext = {
|
||||
description: 'diff for cached changes',
|
||||
handler: async () => {
|
||||
const tempDir = await createTempSubdirectory('devchat/context');
|
||||
const diff_file = path.join(tempDir, 'diff_cached.txt');
|
||||
const diffFile = path.join(tempDir, 'diff_cached.txt');
|
||||
|
||||
logger.channel()?.info(`git diff --cached`);
|
||||
const result = await runCommandStringAndWriteOutput('git diff --cached', diff_file);
|
||||
logger.channel()?.info(`git diff --cached exit code:`, result.exitCode);
|
||||
logger.channel()?.info(`git diff --cached:`);
|
||||
const result = await runCommandStringAndWriteOutput('git diff --cached', diffFile);
|
||||
logger.channel()?.info(` exit code:`, result.exitCode);
|
||||
|
||||
logger.channel()?.debug(`git diff --cached stdout:`, result.stdout);
|
||||
logger.channel()?.debug(`git diff --cached stderr:`, result.stderr);
|
||||
return `[context|${diff_file}]`;
|
||||
logger.channel()?.debug(` stdout:`, result.stdout);
|
||||
logger.channel()?.debug(` stderr:`, result.stderr);
|
||||
return `[context|${diffFile}]`;
|
||||
},
|
||||
};
|
||||
|
@ -42,11 +42,13 @@ export interface ChatContext {
|
||||
const tempDir = await createTempSubdirectory('devchat/context');
|
||||
|
||||
const outputFile = path.join(tempDir, 'context.txt');
|
||||
|
||||
logger.channel()?.info(`running: ${customContext.command.join(' ')}`);
|
||||
const commandResult = await customContexts.handleCommand(customContext.name, outputFile);
|
||||
|
||||
logger.channel()?.info(`${customContext.command.join(' ')} exit code:`, commandResult!.exitCode);
|
||||
logger.channel()?.debug(`stdout:`, commandResult!.stdout);
|
||||
logger.channel()?.debug(`stderr:`, commandResult!.stderr);
|
||||
logger.channel()?.info(` exit code:`, commandResult!.exitCode);
|
||||
logger.channel()?.debug(` stdout:`, commandResult!.stdout);
|
||||
logger.channel()?.debug(` stderr:`, commandResult!.stderr);
|
||||
|
||||
if (commandResult!.stderr) {
|
||||
UiUtilWrapper.showErrorMessage(commandResult!.stderr);
|
||||
|
@ -11,10 +11,10 @@ export async function handleRefCommand(ref_command: string) {
|
||||
|
||||
logger.channel()?.info(`custom command: ${ref_command}`);
|
||||
const result = await runCommandStringAndWriteOutput(ref_command, diff_file);
|
||||
logger.channel()?.info(`custom command: ${ref_command} exit code:`, result.exitCode);
|
||||
logger.channel()?.info(` exit code:`, result.exitCode);
|
||||
|
||||
logger.channel()?.debug(`custom command: ${ref_command} stdout:`, result.stdout);
|
||||
logger.channel()?.debug(`custom command: ${ref_command} stderr:`, result.stderr);
|
||||
logger.channel()?.debug(` stdout:`, result.stdout);
|
||||
logger.channel()?.debug(` stderr:`, result.stderr);
|
||||
return `[context|${diff_file}]`;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class CustomContexts {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.channel()?.error(`Failed to parse contexts: ${error}`);
|
||||
logger.channel()?.error(`Failed to parse contexts due to error: ${error}`);
|
||||
logger.channel()?.show();
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ class CustomContexts {
|
||||
public async handleCommand(contextName: string, outputFile: string): Promise<CommandResult | null> {
|
||||
const context = this.getContext(contextName);
|
||||
if (!context) {
|
||||
logger.channel()?.error(`Context not found: ${contextName}`);
|
||||
logger.channel()?.error(`Context "${contextName}" not found`);
|
||||
logger.channel()?.show();
|
||||
return null;
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ export function checkDevChatDependency(): boolean {
|
||||
runCommand('devchat --help');
|
||||
return true;
|
||||
} else {
|
||||
logger.channel()?.error(`Failed to get pipx environment path, I will try to install pipx.`);
|
||||
logger.channel()?.error(`Failed to obtain the pipx environment path. Attempting to install pipx.`);
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
// DevChat dependency check failed
|
||||
// log out detail error message
|
||||
logger.channel()?.error(`Failed to check DevChat dependency: ${error}`);
|
||||
logger.channel()?.error(`Failed to check DevChat dependency due to error: ${error}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ import { logger } from '../util/logger';
|
||||
|
||||
regOutMessage({command: 'appendContext', context: ''});
|
||||
export async function sendFileSelectMessage(panel: vscode.WebviewPanel|vscode.WebviewView, filePath: string): Promise<void> {
|
||||
logger.channel()?.info(`Append context: ${filePath}`);
|
||||
logger.channel()?.info(`File selected: ${filePath}`);
|
||||
const codeContext = await handleFileSelected(filePath);
|
||||
MessageHandler.sendMessage(panel, { command: 'appendContext', context: codeContext });
|
||||
}
|
||||
|
||||
regOutMessage({command: 'appendContext', context: ''});
|
||||
export async function sendCodeSelectMessage(panel: vscode.WebviewPanel|vscode.WebviewView, filePath: string, codeBlock: string): Promise<void> {
|
||||
logger.channel()?.info(`Append context: ${filePath}`);
|
||||
logger.channel()?.info(`File selected: ${filePath}`);
|
||||
const codeContext = await handleCodeSelected(filePath, codeBlock);
|
||||
MessageHandler.sendMessage(panel, { command: 'appendContext', context: codeContext });
|
||||
}
|
@ -15,6 +15,6 @@ export async function contextDetail(message: any, panel: vscode.WebviewPanel | v
|
||||
const fileContent = fs.readFileSync(message.file, 'utf-8');
|
||||
MessageHandler.sendMessage(panel, { command: 'contextDetailResponse', 'file': message.file, result: fileContent });
|
||||
} catch (error) {
|
||||
logger.channel()?.error(`Error reading file ${ message.file }:, ${error}`);
|
||||
logger.channel()?.error(`Error reading file ${message.file}: ${error}`);
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ export class MessageHandler {
|
||||
|
||||
const handler = this.handlers[message.command];
|
||||
if (handler) {
|
||||
logger.channel()?.info(`Handling command "${message.command}"`);
|
||||
logger.channel()?.info(`Handling the command "${message.command}"`);
|
||||
await handler(message, panel);
|
||||
logger.channel()?.info(`Handling command "${message.command}" done`);
|
||||
logger.channel()?.info(`Handling the command "${message.command}" done`);
|
||||
} else {
|
||||
logger.channel()?.error(`No handler found for command "${message.command}"`);
|
||||
logger.channel()?.error(`No handler found for the command "${message.command}"`);
|
||||
logger.channel()?.show();
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ export class MessageHandler {
|
||||
|
||||
public static sendMessage(panel: vscode.WebviewPanel|vscode.WebviewView, message: object, log: boolean = true): void {
|
||||
if (log) {
|
||||
logger.channel()?.info(`Sending message "${JSON.stringify(message)}"`);
|
||||
logger.channel()?.info(`Sending message: "${JSON.stringify(message)}"`);
|
||||
}
|
||||
panel.webview.postMessage(message);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ async function getFileContent(fileName: string): Promise<string | undefined> {
|
||||
// Return the whole text in the file with name fileName
|
||||
return fileContent;
|
||||
} catch (error) {
|
||||
logger.channel()!.error(`Error reading file ${fileName}:`, error);
|
||||
logger.channel()!.error(`Error reading the file ${fileName}:`, error);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ async function getNewCode(message: any): Promise<string | undefined> {
|
||||
if (message.fileName) {
|
||||
const fileContent = await getFileContent(message.fileName);
|
||||
if (!fileContent) {
|
||||
logger.channel()!.error(`read file ${message.fileName} failed`);
|
||||
logger.channel()!.error(`Failed to read the file: ${message.fileName}`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ async function getNewCode(message: any): Promise<string | undefined> {
|
||||
codeTextObj = await getDocumentText();
|
||||
}
|
||||
if (!codeTextObj) {
|
||||
logger.channel()!.error('getDocumentText failed');
|
||||
logger.channel()!.error('No document text found.');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ export function createChatDirectoryAndCopyInstructionsSync(extensionUri: vscode.
|
||||
// 将 workflows 目录复制到 .chat 目录中
|
||||
copyDirSync(instructionsSrcPath, chatWorkflowsDirPath);
|
||||
} catch (error) {
|
||||
logger.channel()?.error('Error creating .chat directory and copying workflows:', error);
|
||||
logger.channel()?.error('Error occurred while creating the .chat directory and copying workflows:', error);
|
||||
logger.channel()?.show();
|
||||
}
|
||||
}
|
@ -152,7 +152,7 @@ class DevChat {
|
||||
const workspaceDir = UiUtilWrapper.workspaceFoldersFirstPath();
|
||||
let openaiApiKey = await ApiKeyManager.getApiKey();
|
||||
if (!openaiApiKey) {
|
||||
logger.channel()?.error('OpenAI key is invalid!');
|
||||
logger.channel()?.error('The OpenAI key is invalid!');
|
||||
logger.channel()?.show();
|
||||
}
|
||||
|
||||
@ -205,8 +205,8 @@ class DevChat {
|
||||
},
|
||||
};
|
||||
|
||||
logger.channel()?.info(`Running devchat with args: ${args.join(" ")}`);
|
||||
logger.channel()?.info(`Running devchat with env: ${JSON.stringify(openAiApiBaseObject)}`);
|
||||
logger.channel()?.info(`Running devchat with arguments: ${args.join(" ")}`);
|
||||
logger.channel()?.info(`Running devchat with environment: ${JSON.stringify(openAiApiBaseObject)}`);
|
||||
const { exitCode: code, stdout, stderr } = await this.commandRun.spawnAsync(devChat, args, spawnAsyncOptions, onStdoutPartial, undefined, undefined, undefined);
|
||||
|
||||
if (stderr) {
|
||||
@ -238,7 +238,7 @@ class DevChat {
|
||||
const workspaceDir = UiUtilWrapper.workspaceFoldersFirstPath();
|
||||
const openaiApiKey = process.env.OPENAI_API_KEY;
|
||||
|
||||
logger.channel()?.info(`Running devchat with args: ${args.join(" ")}`);
|
||||
logger.channel()?.info(`Running devchat with arguments: ${args.join(" ")}`);
|
||||
const spawnOptions = {
|
||||
maxBuffer: 10 * 1024 * 1024, // Set maxBuffer to 10 MB
|
||||
cwd: workspaceDir,
|
||||
@ -249,9 +249,9 @@ class DevChat {
|
||||
};
|
||||
const { exitCode: code, stdout, stderr } = await this.commandRun.spawnAsync(devChat, args, spawnOptions, undefined, undefined, undefined, undefined);
|
||||
|
||||
logger.channel()?.info(`Finish devchat with args: ${args.join(" ")}`);
|
||||
logger.channel()?.info(`Finish devchat with arguments: ${args.join(" ")}`);
|
||||
if (stderr) {
|
||||
logger.channel()?.error(`Error getting log: ${stderr}`);
|
||||
logger.channel()?.error(`Error: ${stderr}`);
|
||||
logger.channel()?.show();
|
||||
return [];
|
||||
}
|
||||
@ -264,7 +264,7 @@ class DevChat {
|
||||
const devChat = this.getDevChatPath();
|
||||
const workspaceDir = UiUtilWrapper.workspaceFoldersFirstPath();
|
||||
|
||||
logger.channel()?.info(`Running devchat with args: ${args.join(" ")}`);
|
||||
logger.channel()?.info(`Running devchat with arguments: ${args.join(" ")}`);
|
||||
const spawnOptions = {
|
||||
maxBuffer: 10 * 1024 * 1024, // Set maxBuffer to 10 MB
|
||||
cwd: workspaceDir,
|
||||
@ -274,9 +274,9 @@ class DevChat {
|
||||
};
|
||||
const { exitCode: code, stdout, stderr } = await this.commandRun.spawnAsync(devChat, args, spawnOptions, undefined, undefined, undefined, undefined);
|
||||
|
||||
logger.channel()?.info(`Finish devchat with args: ${args.join(" ")}`);
|
||||
logger.channel()?.info(`Finish devchat with arguments: ${args.join(" ")}`);
|
||||
if (stderr) {
|
||||
logger.channel()?.error(`Error getting log: ${stderr}`);
|
||||
logger.channel()?.error(`Error: ${stderr}`);
|
||||
logger.channel()?.show();
|
||||
return [];
|
||||
}
|
||||
@ -284,7 +284,7 @@ class DevChat {
|
||||
try {
|
||||
return JSON.parse(stdout.trim()).reverse();
|
||||
} catch (error) {
|
||||
logger.channel()?.error(`Error parsing log: ${error}`);
|
||||
logger.channel()?.error(`Error parsing JSON: ${error}`);
|
||||
logger.channel()?.show();
|
||||
return [];
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class DtmWrapper {
|
||||
return { status: result.exitCode || 0, message: result.stdout, log: result.stderr };
|
||||
} catch (error) {
|
||||
// 处理 runCommand 中的 reject 错误
|
||||
logger.channel()?.error(`Error in commit: ${error}`);
|
||||
logger.channel()?.error(`Error: ${error}`);
|
||||
logger.channel()?.show();
|
||||
return error as DtmResponse;
|
||||
}
|
||||
@ -41,7 +41,7 @@ class DtmWrapper {
|
||||
return { status: result.exitCode || 0, message: result.stdout, log: result.stderr };
|
||||
} catch (error) {
|
||||
// 处理 runCommand 中的 reject 错误
|
||||
logger.channel()?.error(`Error in commit: ${error}`);
|
||||
logger.channel()?.error(`Error: ${error}`);
|
||||
logger.channel()?.show();
|
||||
return error as DtmResponse;
|
||||
}
|
||||
|
@ -89,10 +89,10 @@ export class CommandRun {
|
||||
let errorMessage = error.message;
|
||||
if (error.code === 'ENOENT') {
|
||||
errorMessage = `Command not found: ${command}`;
|
||||
logger.channel()?.error(`Command not found: ${command}`);
|
||||
logger.channel()?.error(`Command "${command}" not found`);
|
||||
logger.channel()?.show();
|
||||
} else {
|
||||
logger.channel()?.error(`Error occurred: ${error.message}`);
|
||||
logger.channel()?.error(`Error: ${error.message}`);
|
||||
logger.channel()?.show();
|
||||
}
|
||||
resolve({ exitCode: error.code, stdout: "", stderr: errorMessage });
|
||||
|
Loading…
x
Reference in New Issue
Block a user