Clean up deprecated logs (#987)

This commit is contained in:
Jinbo Wang 2021-04-26 11:18:05 +08:00 committed by GitHub
parent 09ea696337
commit b74c374def
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 23 additions and 98 deletions

View File

@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Show VARIABLES with different data views. [PR#982](https://github.com/microsoft/vscode-java-debug/pull/982). - Show VARIABLES with different data views. [PR#982](https://github.com/microsoft/vscode-java-debug/pull/982).
- Adopt new APIs from vscode-tas-client. [#974](https://github.com/microsoft/vscode-java-debug/pull/974). - Adopt new APIs from vscode-tas-client. [#974](https://github.com/microsoft/vscode-java-debug/pull/974).
### Changed
- Engineering: Clean up deprecated logs. [PR#987](https://github.com/microsoft/vscode-java-debug/pull/987).
### Fixed ### Fixed
- Breakpoints inside record methods don't work. [#973](https://github.com/microsoft/vscode-java-debug/issues/973). - Breakpoints inside record methods don't work. [#973](https://github.com/microsoft/vscode-java-debug/issues/973).
- Support environment variable for port number in launch.json debug configuration. [#962](https://github.com/microsoft/vscode-java-debug/issues/962). - Support environment variable for port number in launch.json debug configuration. [#962](https://github.com/microsoft/vscode-java-debug/issues/962).

12
package-lock.json generated
View File

@ -3208,9 +3208,9 @@
} }
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true "dev": true
}, },
"yargs": { "yargs": {
@ -5408,9 +5408,9 @@
} }
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true "dev": true
}, },
"yargs": { "yargs": {

View File

@ -535,7 +535,10 @@
"description": "%java.debugger.attach.hostName.description%" "description": "%java.debugger.attach.hostName.description%"
}, },
"port": { "port": {
"type": ["number", "string"], "type": [
"number",
"string"
],
"description": "%java.debugger.attach.port.description%" "description": "%java.debugger.attach.port.description%"
}, },
"processId": { "processId": {
@ -917,7 +920,6 @@
"compare-versions": "^3.6.0", "compare-versions": "^3.6.0",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"uuid": "^8.3.1", "uuid": "^8.3.1",
"vscode-extension-telemetry": "^0.1.6",
"vscode-extension-telemetry-wrapper": "^0.9.0", "vscode-extension-telemetry-wrapper": "^0.9.0",
"vscode-languageclient": "6.0.0-next.9", "vscode-languageclient": "6.0.0-next.9",
"vscode-languageserver-types": "3.16.0", "vscode-languageserver-types": "3.16.0",

View File

@ -11,9 +11,9 @@ import * as anchor from "./anchor";
import { buildWorkspace } from "./build"; import { buildWorkspace } from "./build";
import { populateStepFilters, substituteFilterVariables } from "./classFilter"; import { populateStepFilters, substituteFilterVariables } from "./classFilter";
import * as commands from "./commands"; import * as commands from "./commands";
import { Type } from "./javaLogger";
import * as lsPlugin from "./languageServerPlugin"; import * as lsPlugin from "./languageServerPlugin";
import { addMoreHelpfulVMArgs, getJavaVersion, getShortenApproachForCLI, validateRuntimeCompatibility } from "./launchCommand"; import { addMoreHelpfulVMArgs, getJavaVersion, getShortenApproachForCLI, validateRuntimeCompatibility } from "./launchCommand";
import { logger, Type } from "./logger";
import { mainClassPicker } from "./mainClassPicker"; import { mainClassPicker } from "./mainClassPicker";
import { resolveJavaProcess } from "./processPicker"; import { resolveJavaProcess } from "./processPicker";
import { IProgressReporter } from "./progressAPI"; import { IProgressReporter } from "./progressAPI";
@ -477,12 +477,6 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
fix: "yes", fix: "yes",
fixMessage: errors.join(os.EOL), fixMessage: errors.join(os.EOL),
}); });
// Deprecated
logger.log(Type.USAGEDATA, {
fix: "yes",
fixMessage: errors.join(os.EOL),
});
await this.persistMainClassOption(folder, config, selectedFix); await this.persistMainClassOption(folder, config, selectedFix);
} }

View File

@ -18,7 +18,6 @@ import { JavaDebugAdapterDescriptorFactory } from "./javaDebugAdapterDescriptorF
import { JavaInlineValuesProvider } from "./JavaInlineValueProvider"; import { JavaInlineValuesProvider } from "./JavaInlineValueProvider";
import { logJavaException, logJavaInfo } from "./javaLogger"; import { logJavaException, logJavaInfo } from "./javaLogger";
import { IMainClassOption, IMainMethod, resolveMainMethod } from "./languageServerPlugin"; import { IMainClassOption, IMainMethod, resolveMainMethod } from "./languageServerPlugin";
import { logger, Type } from "./logger";
import { mainClassPicker } from "./mainClassPicker"; import { mainClassPicker } from "./mainClassPicker";
import { pickJavaProcess } from "./processPicker"; import { pickJavaProcess } from "./processPicker";
import { IProgressReporter } from "./progressAPI"; import { IProgressReporter } from "./progressAPI";
@ -37,12 +36,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
} }
function initializeExtension(_operationId: string, context: vscode.ExtensionContext): any { function initializeExtension(_operationId: string, context: vscode.ExtensionContext): any {
// Deprecated
logger.initialize(context, true);
registerDebugEventListener(context); registerDebugEventListener(context);
registerVariableMenuCommands(context); registerVariableMenuCommands(context);
context.subscriptions.push(logger);
context.subscriptions.push(vscode.window.registerTerminalLinkProvider(new JavaTerminalLinkProvder())); context.subscriptions.push(vscode.window.registerTerminalLinkProvider(new JavaTerminalLinkProvder()));
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider("java", new JavaDebugConfigurationProvider())); context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider("java", new JavaDebugConfigurationProvider()));
context.subscriptions.push(vscode.debug.registerDebugAdapterDescriptorFactory("java", new JavaDebugAdapterDescriptorFactory())); context.subscriptions.push(vscode.debug.registerDebugAdapterDescriptorFactory("java", new JavaDebugAdapterDescriptorFactory()));
@ -115,9 +110,6 @@ function registerDebugEventListener(context: vscode.ExtensionContext) {
} else { } else {
logJavaInfo(commonProperties, measureProperties); logJavaInfo(commonProperties, measureProperties);
} }
// Deprecated
logger.log(entry.scope === "exception" ? Type.EXCEPTION : Type.USAGEDATA, commonProperties, measureProperties);
}); });
} }
}); });

View File

@ -2,9 +2,8 @@
// Licensed under the MIT license. // Licensed under the MIT license.
import { DebugAdapterDescriptor, DebugAdapterDescriptorFactory, DebugAdapterExecutable, DebugAdapterServer, DebugSession } from "vscode"; import { DebugAdapterDescriptor, DebugAdapterDescriptorFactory, DebugAdapterExecutable, DebugAdapterServer, DebugSession } from "vscode";
import { Type } from "./javaLogger";
import { startDebugSession } from "./languageServerPlugin"; import { startDebugSession } from "./languageServerPlugin";
import { Type } from "./logger";
import { convertErrorToMessage, showErrorMessageWithTroubleshooting } from "./utility"; import { convertErrorToMessage, showErrorMessageWithTroubleshooting } from "./utility";
export class JavaDebugAdapterDescriptorFactory implements DebugAdapterDescriptorFactory { export class JavaDebugAdapterDescriptorFactory implements DebugAdapterDescriptorFactory {

View File

@ -3,6 +3,13 @@
import { sendInfo, sendOperationError } from "vscode-extension-telemetry-wrapper"; import { sendInfo, sendOperationError } from "vscode-extension-telemetry-wrapper";
export enum Type {
EXCEPTION = "exception",
USAGEDATA = "usageData",
USAGEERROR = "usageError",
ACTIVATEEXTENSION = "activateExtension", // TODO: Activation belongs to usage data, remove this category.
}
export function logJavaException(errorProperties: any): void { export function logJavaException(errorProperties: any): void {
/** /**
* A sample errorProperties from Java code. * A sample errorProperties from Java code.

View File

@ -1,63 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as fs from "fs";
import * as vscode from "vscode";
import TelemetryReporter from "vscode-extension-telemetry";
export enum Type {
EXCEPTION = "exception",
USAGEDATA = "usageData",
USAGEERROR = "usageError",
ACTIVATEEXTENSION = "activateExtension", // TODO: Activation belongs to usage data, remove this category.
}
const SENSITIVE_PROPS = ["message", "stacktrace", "detailmessage"];
// Deprecate
class Logger implements vscode.Disposable {
private reporter: TelemetryReporter | null = null;
public initialize(context: vscode.ExtensionContext, firstParty?: boolean): void {
if (this.reporter) {
return;
}
const extensionPackage = JSON.parse(fs.readFileSync(context.asAbsolutePath("./package.json"), "utf-8"));
if (extensionPackage) {
const aiKey = extensionPackage.aiKey instanceof Array ? extensionPackage.aiKey[0] : extensionPackage.aiKey;
const packageInfo = {
name: extensionPackage.name,
version: extensionPackage.version,
aiKey,
};
if (packageInfo.aiKey) {
this.reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey, firstParty);
}
}
}
public log(type: Type, properties?: { [key: string]: string; }, measures?: { [key: string]: number; }): void {
if (!this.reporter) {
return;
}
if (type === Type.EXCEPTION || type === Type.USAGEERROR) {
this.reporter.sendTelemetryErrorEvent(type, properties, measures, SENSITIVE_PROPS);
} else {
this.reporter.sendTelemetryEvent(type, properties, measures);
}
}
public logMessage(type: Type, message: string): void {
this.log(type, { message });
}
public dispose() {
if (this.reporter) {
this.reporter.dispose();
}
}
}
export const logger = new Logger();

View File

@ -4,8 +4,8 @@
import * as path from "path"; import * as path from "path";
import * as vscode from "vscode"; import * as vscode from "vscode";
import { sendError, sendInfo, setUserError } from "vscode-extension-telemetry-wrapper"; import { sendError, sendInfo, setUserError } from "vscode-extension-telemetry-wrapper";
import { Type } from "./javaLogger";
import { IMainClassOption, resolveMainClass } from "./languageServerPlugin"; import { IMainClassOption, resolveMainClass } from "./languageServerPlugin";
import { logger, Type } from "./logger";
import { IProgressReporter } from "./progressAPI"; import { IProgressReporter } from "./progressAPI";
const TROUBLESHOOTING_LINK = "https://github.com/Microsoft/vscode-java-debug/blob/master/Troubleshooting.md"; const TROUBLESHOOTING_LINK = "https://github.com/Microsoft/vscode-java-debug/blob/master/Troubleshooting.md";
@ -64,9 +64,6 @@ function logMessage(message: ILoggingMessage): void {
} else { } else {
sendInfo("", { message: message.message }); sendInfo("", { message: message.message });
} }
// Deprecated
logger.log(message.type, { message: message.message, stack: message.stack || "" });
} }
export async function showInformationMessage(message: ILoggingMessage, ...items: string[]): Promise<string | undefined> { export async function showInformationMessage(message: ILoggingMessage, ...items: string[]): Promise<string | undefined> {
@ -114,12 +111,6 @@ export function openTroubleshootingPage(message: string, anchor?: string) {
troubleshooting: "yes", troubleshooting: "yes",
troubleshootingMessage: message, troubleshootingMessage: message,
}); });
// Deprecated
logger.log(Type.USAGEDATA, {
troubleshooting: "yes",
troubleshootingMessage: message,
});
} }
export async function guideToInstallJavaExtension() { export async function guideToInstallJavaExtension() {