parent
58399f1f68
commit
6be3f02482
|
@ -12,7 +12,7 @@ import { Schemes } from './configuration/schemes';
|
|||
import { IExperimentationTelemetryReporter } from './experimentTelemetryReporter';
|
||||
import { DiagnosticKind, DiagnosticsManager } from './languageFeatures/diagnostics';
|
||||
import { Logger } from './logging/logger';
|
||||
import { TelemetryProperties, TelemetryReporter, VSCodeTelemetryReporter } from './logging/telemetry';
|
||||
import { TelemetryReporter, VSCodeTelemetryReporter } from './logging/telemetry';
|
||||
import Tracer from './logging/tracer';
|
||||
import { ProjectType, inferredProjectCompilerOptions } from './tsconfig';
|
||||
import { API } from './tsServer/api';
|
||||
|
@ -319,7 +319,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
|
||||
public restartTsServer(fromUserAction = false): void {
|
||||
if (this.serverState.type === ServerState.Type.Running) {
|
||||
this.info('Killing TS Server');
|
||||
this.logger.info('Killing TS Server');
|
||||
this.isRestarting = true;
|
||||
this.serverState.server.kill();
|
||||
}
|
||||
|
@ -372,18 +372,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
return this._onReady!.promise.then(f);
|
||||
}
|
||||
|
||||
private info(message: string, ...data: any[]): void {
|
||||
this.logger.info(message, ...data);
|
||||
}
|
||||
|
||||
private error(message: string, ...data: any[]): void {
|
||||
this.logger.error(message, ...data);
|
||||
}
|
||||
|
||||
private logTelemetry(eventName: string, properties?: TelemetryProperties) {
|
||||
this.telemetryReporter.logTelemetry(eventName, properties);
|
||||
}
|
||||
|
||||
public ensureServiceStarted() {
|
||||
if (this.serverState.type !== ServerState.Type.Running) {
|
||||
this.startService();
|
||||
|
@ -392,15 +380,15 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
|
||||
private token: number = 0;
|
||||
private startService(resendModels: boolean = false): ServerState.State {
|
||||
this.info(`Starting TS Server`);
|
||||
this.logger.info(`Starting TS Server`);
|
||||
|
||||
if (this.isDisposed) {
|
||||
this.info(`Not starting server: disposed`);
|
||||
this.logger.info(`Not starting server: disposed`);
|
||||
return ServerState.None;
|
||||
}
|
||||
|
||||
if (this.hasServerFatallyCrashedTooManyTimes) {
|
||||
this.info(`Not starting server: too many crashes`);
|
||||
this.logger.info(`Not starting server: too many crashes`);
|
||||
return ServerState.None;
|
||||
}
|
||||
|
||||
|
@ -412,10 +400,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
version = this._versionManager.currentVersion;
|
||||
}
|
||||
|
||||
this.info(`Using tsserver from: ${version.path}`);
|
||||
this.logger.info(`Using tsserver from: ${version.path}`);
|
||||
const nodePath = this._nodeVersionManager.currentVersion;
|
||||
if (nodePath) {
|
||||
this.info(`Using Node installation from ${nodePath} to run TS Server`);
|
||||
this.logger.info(`Using Node installation from ${nodePath} to run TS Server`);
|
||||
}
|
||||
|
||||
this.resetWatchers();
|
||||
|
@ -451,7 +439,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
"typeScriptVersionSource": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.logTelemetry('tsserver.spawned', {
|
||||
this.telemetryReporter.logTelemetry('tsserver.spawned', {
|
||||
...typeScriptServerEnvCommonProperties,
|
||||
localTypeScriptVersion: this.versionProvider.localVersion ? this.versionProvider.localVersion.displayName : '',
|
||||
typeScriptVersionSource: version.source,
|
||||
|
@ -468,9 +456,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
}
|
||||
|
||||
this.serverState = new ServerState.Errored(err, handle.tsServerLog);
|
||||
this.error('TSServer errored with error.', err);
|
||||
this.logger.error('TSServer errored with error.', err);
|
||||
if (handle.tsServerLog?.type === 'file') {
|
||||
this.error(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
|
||||
this.logger.error(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
|
||||
}
|
||||
|
||||
/* __GDPR__
|
||||
|
@ -482,7 +470,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
]
|
||||
}
|
||||
*/
|
||||
this.logTelemetry('tsserver.error', {
|
||||
this.telemetryReporter.logTelemetry('tsserver.error', {
|
||||
...typeScriptServerEnvCommonProperties
|
||||
});
|
||||
this.serviceExited(false, apiVersion);
|
||||
|
@ -490,7 +478,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
|
||||
handle.onExit((data: TypeScriptServerExitEvent) => {
|
||||
const { code, signal } = data;
|
||||
this.error(`TSServer exited. Code: ${code}. Signal: ${signal}`);
|
||||
this.logger.error(`TSServer exited. Code: ${code}. Signal: ${signal}`);
|
||||
|
||||
// In practice, the exit code is an integer with no ties to any identity,
|
||||
// so it can be classified as SystemMetaData, rather than CallstackOrException.
|
||||
|
@ -505,7 +493,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
"signal" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
}
|
||||
*/
|
||||
this.logTelemetry('tsserver.exitWithCode', {
|
||||
this.telemetryReporter.logTelemetry('tsserver.exitWithCode', {
|
||||
...typeScriptServerEnvCommonProperties,
|
||||
code: code ?? undefined,
|
||||
signal: signal ?? undefined,
|
||||
|
@ -517,7 +505,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
}
|
||||
|
||||
if (handle.tsServerLog?.type === 'file') {
|
||||
this.info(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
|
||||
this.logger.info(`TSServer log file: ${handle.tsServerLog.uri.fsPath}`);
|
||||
}
|
||||
this.serviceExited(!this.isRestarting, apiVersion);
|
||||
this.isRestarting = false;
|
||||
|
@ -678,7 +666,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
]
|
||||
}
|
||||
*/
|
||||
this.logTelemetry('serviceExited');
|
||||
this.telemetryReporter.logTelemetry('serviceExited');
|
||||
} else if (diff < 60 * 1000 * 5 /* 5 Minutes */) {
|
||||
this.lastStart = Date.now();
|
||||
if (!this._isPromptingAfterCrash) {
|
||||
|
@ -956,14 +944,14 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
"command" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.logTelemetry('fatalError', { ...(error instanceof TypeScriptServerError ? error.telemetry : { command }) });
|
||||
this.telemetryReporter.logTelemetry('fatalError', { ...(error instanceof TypeScriptServerError ? error.telemetry : { command }) });
|
||||
console.error(`A non-recoverable error occurred while executing tsserver command: ${command}`);
|
||||
if (error instanceof TypeScriptServerError && error.serverErrorText) {
|
||||
console.error(error.serverErrorText);
|
||||
}
|
||||
|
||||
if (this.serverState.type === ServerState.Type.Running) {
|
||||
this.info('Killing TS Server');
|
||||
this.logger.info('Killing TS Server');
|
||||
const logfile = this.serverState.server.tsServerLog;
|
||||
this.serverState.server.kill();
|
||||
if (error instanceof TypeScriptServerError) {
|
||||
|
@ -1235,7 +1223,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
|||
}
|
||||
*/
|
||||
// __GDPR__COMMENT__: Other events are defined by TypeScript.
|
||||
this.logTelemetry(telemetryData.telemetryEventName, properties);
|
||||
this.telemetryReporter.logTelemetry(telemetryData.telemetryEventName, properties);
|
||||
}
|
||||
|
||||
private configurePlugin(pluginName: string, configuration: {}): any {
|
||||
|
|
Loading…
Reference in New Issue