fix: Better log required information (#1434)

Signed-off-by: Sheng Chen <sheche@microsoft.com>
This commit is contained in:
Sheng Chen 2023-10-17 23:46:42 -07:00 коммит произвёл GitHub
Родитель 6462613fba
Коммит e0b4554c43
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 29 добавлений и 18 удалений

Просмотреть файл

@ -91,38 +91,43 @@ export class BuildServerController implements Disposable {
}
})
);
this.checkGradleExecutable();
this.checkProxy();
this.checkMachineStatus();
}
public dispose() {
this.disposable.dispose();
}
private checkGradleExecutable(): void {
private checkMachineStatus() {
const machineStatus: { [key: string]: string } = {};
if (this.isGradleExecutableOnPath()) {
machineStatus.gradleExecutableFound = "true";
}
if (this.hasProxy()) {
machineStatus.hasProxy = "true";
}
if (Object.keys(machineStatus).length > 0) {
sendInfo("", {
kind: "machineStatus",
data: JSON.stringify(machineStatus),
});
}
}
private isGradleExecutableOnPath(): boolean {
if (process.env.PATH) {
const pathDirectories = process.env.PATH.split(path.delimiter);
for (const dir of pathDirectories) {
const executablePath = path.join(dir, "gradle");
if (fse.existsSync(executablePath) && fse.statSync(executablePath).isFile()) {
sendInfo("", {
kind: "hasGradleExecutableInPath",
data: "true",
});
return;
return true;
}
}
}
return false;
}
private checkProxy(): void {
const proxy =
process.env.HTTP_PROXY ?? process.env.HTTPS_PROXY ?? workspace.getConfiguration("http").get("proxy");
if (proxy) {
sendInfo("", {
kind: "hasProxy",
data: "true",
});
}
private hasProxy(): boolean {
return !!(process.env.HTTP_PROXY || process.env.HTTPS_PROXY || workspace.getConfiguration("http").get("proxy"));
}
}

Просмотреть файл

@ -1,4 +1,5 @@
import * as vscode from "vscode";
import { sendInfo } from "vscode-extension-telemetry-wrapper";
export enum LogVerbosity {
DEBUG = 0,
@ -51,7 +52,12 @@ export class Logger {
}
public error(...messages: string[]): void {
this.log(messages.join(" "), LogVerbosity.ERROR);
const error = messages.join(" ");
this.log(error, LogVerbosity.ERROR);
sendInfo("", {
kind: "gradleTaskServerError",
data: error,
});
}
public debug(...messages: string[]): void {