@@ -12,7 +12,7 @@ import { Schemes } from './configuration/schemes';
12
12
import { IExperimentationTelemetryReporter } from './experimentTelemetryReporter' ;
13
13
import { DiagnosticKind , DiagnosticsManager } from './languageFeatures/diagnostics' ;
14
14
import { Logger } from './logging/logger' ;
15
- import { TelemetryProperties , TelemetryReporter , VSCodeTelemetryReporter } from './logging/telemetry' ;
15
+ import { TelemetryReporter , VSCodeTelemetryReporter } from './logging/telemetry' ;
16
16
import Tracer from './logging/tracer' ;
17
17
import { ProjectType , inferredProjectCompilerOptions } from './tsconfig' ;
18
18
import { API } from './tsServer/api' ;
@@ -319,7 +319,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
319
319
320
320
public restartTsServer ( fromUserAction = false ) : void {
321
321
if ( this . serverState . type === ServerState . Type . Running ) {
322
- this . info ( 'Killing TS Server' ) ;
322
+ this . logger . info ( 'Killing TS Server' ) ;
323
323
this . isRestarting = true ;
324
324
this . serverState . server . kill ( ) ;
325
325
}
@@ -372,18 +372,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
372
372
return this . _onReady ! . promise . then ( f ) ;
373
373
}
374
374
375
- private info ( message : string , ...data : any [ ] ) : void {
376
- this . logger . info ( message , ...data ) ;
377
- }
378
-
379
- private error ( message : string , ...data : any [ ] ) : void {
380
- this . logger . error ( message , ...data ) ;
381
- }
382
-
383
- private logTelemetry ( eventName : string , properties ?: TelemetryProperties ) {
384
- this . telemetryReporter . logTelemetry ( eventName , properties ) ;
385
- }
386
-
387
375
public ensureServiceStarted ( ) {
388
376
if ( this . serverState . type !== ServerState . Type . Running ) {
389
377
this . startService ( ) ;
@@ -392,15 +380,15 @@ export default class TypeScriptServiceClient extends Disposable implements IType
392
380
393
381
private token : number = 0 ;
394
382
private startService ( resendModels : boolean = false ) : ServerState . State {
395
- this . info ( `Starting TS Server` ) ;
383
+ this . logger . info ( `Starting TS Server` ) ;
396
384
397
385
if ( this . isDisposed ) {
398
- this . info ( `Not starting server: disposed` ) ;
386
+ this . logger . info ( `Not starting server: disposed` ) ;
399
387
return ServerState . None ;
400
388
}
401
389
402
390
if ( this . hasServerFatallyCrashedTooManyTimes ) {
403
- this . info ( `Not starting server: too many crashes` ) ;
391
+ this . logger . info ( `Not starting server: too many crashes` ) ;
404
392
return ServerState . None ;
405
393
}
406
394
@@ -412,10 +400,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
412
400
version = this . _versionManager . currentVersion ;
413
401
}
414
402
415
- this . info ( `Using tsserver from: ${ version . path } ` ) ;
403
+ this . logger . info ( `Using tsserver from: ${ version . path } ` ) ;
416
404
const nodePath = this . _nodeVersionManager . currentVersion ;
417
405
if ( nodePath ) {
418
- this . info ( `Using Node installation from ${ nodePath } to run TS Server` ) ;
406
+ this . logger . info ( `Using Node installation from ${ nodePath } to run TS Server` ) ;
419
407
}
420
408
421
409
this . resetWatchers ( ) ;
@@ -451,7 +439,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
451
439
"typeScriptVersionSource": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
452
440
}
453
441
*/
454
- this . logTelemetry ( 'tsserver.spawned' , {
442
+ this . telemetryReporter . logTelemetry ( 'tsserver.spawned' , {
455
443
...typeScriptServerEnvCommonProperties ,
456
444
localTypeScriptVersion : this . versionProvider . localVersion ? this . versionProvider . localVersion . displayName : '' ,
457
445
typeScriptVersionSource : version . source ,
@@ -468,9 +456,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType
468
456
}
469
457
470
458
this . serverState = new ServerState . Errored ( err , handle . tsServerLog ) ;
471
- this . error ( 'TSServer errored with error.' , err ) ;
459
+ this . logger . error ( 'TSServer errored with error.' , err ) ;
472
460
if ( handle . tsServerLog ?. type === 'file' ) {
473
- this . error ( `TSServer log file: ${ handle . tsServerLog . uri . fsPath } ` ) ;
461
+ this . logger . error ( `TSServer log file: ${ handle . tsServerLog . uri . fsPath } ` ) ;
474
462
}
475
463
476
464
/* __GDPR__
@@ -482,15 +470,15 @@ export default class TypeScriptServiceClient extends Disposable implements IType
482
470
]
483
471
}
484
472
*/
485
- this . logTelemetry ( 'tsserver.error' , {
473
+ this . telemetryReporter . logTelemetry ( 'tsserver.error' , {
486
474
...typeScriptServerEnvCommonProperties
487
475
} ) ;
488
476
this . serviceExited ( false , apiVersion ) ;
489
477
} ) ;
490
478
491
479
handle . onExit ( ( data : TypeScriptServerExitEvent ) => {
492
480
const { code, signal } = data ;
493
- this . error ( `TSServer exited. Code: ${ code } . Signal: ${ signal } ` ) ;
481
+ this . logger . error ( `TSServer exited. Code: ${ code } . Signal: ${ signal } ` ) ;
494
482
495
483
// In practice, the exit code is an integer with no ties to any identity,
496
484
// so it can be classified as SystemMetaData, rather than CallstackOrException.
@@ -505,7 +493,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
505
493
"signal" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
506
494
}
507
495
*/
508
- this . logTelemetry ( 'tsserver.exitWithCode' , {
496
+ this . telemetryReporter . logTelemetry ( 'tsserver.exitWithCode' , {
509
497
...typeScriptServerEnvCommonProperties ,
510
498
code : code ?? undefined ,
511
499
signal : signal ?? undefined ,
@@ -517,7 +505,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
517
505
}
518
506
519
507
if ( handle . tsServerLog ?. type === 'file' ) {
520
- this . info ( `TSServer log file: ${ handle . tsServerLog . uri . fsPath } ` ) ;
508
+ this . logger . info ( `TSServer log file: ${ handle . tsServerLog . uri . fsPath } ` ) ;
521
509
}
522
510
this . serviceExited ( ! this . isRestarting , apiVersion ) ;
523
511
this . isRestarting = false ;
@@ -678,7 +666,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
678
666
]
679
667
}
680
668
*/
681
- this . logTelemetry ( 'serviceExited' ) ;
669
+ this . telemetryReporter . logTelemetry ( 'serviceExited' ) ;
682
670
} else if ( diff < 60 * 1000 * 5 /* 5 Minutes */ ) {
683
671
this . lastStart = Date . now ( ) ;
684
672
if ( ! this . _isPromptingAfterCrash ) {
@@ -956,14 +944,14 @@ export default class TypeScriptServiceClient extends Disposable implements IType
956
944
"command" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
957
945
}
958
946
*/
959
- this . logTelemetry ( 'fatalError' , { ...( error instanceof TypeScriptServerError ? error . telemetry : { command } ) } ) ;
947
+ this . telemetryReporter . logTelemetry ( 'fatalError' , { ...( error instanceof TypeScriptServerError ? error . telemetry : { command } ) } ) ;
960
948
console . error ( `A non-recoverable error occurred while executing tsserver command: ${ command } ` ) ;
961
949
if ( error instanceof TypeScriptServerError && error . serverErrorText ) {
962
950
console . error ( error . serverErrorText ) ;
963
951
}
964
952
965
953
if ( this . serverState . type === ServerState . Type . Running ) {
966
- this . info ( 'Killing TS Server' ) ;
954
+ this . logger . info ( 'Killing TS Server' ) ;
967
955
const logfile = this . serverState . server . tsServerLog ;
968
956
this . serverState . server . kill ( ) ;
969
957
if ( error instanceof TypeScriptServerError ) {
@@ -1235,7 +1223,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
1235
1223
}
1236
1224
*/
1237
1225
// __GDPR__COMMENT__: Other events are defined by TypeScript.
1238
- this . logTelemetry ( telemetryData . telemetryEventName , properties ) ;
1226
+ this . telemetryReporter . logTelemetry ( telemetryData . telemetryEventName , properties ) ;
1239
1227
}
1240
1228
1241
1229
private configurePlugin ( pluginName : string , configuration : { } ) : any {
0 commit comments