@@ -22,6 +22,8 @@ import { truncateUuid } from './crypto'
22
22
23
23
const className = 'CrashMonitoring'
24
24
25
+ const logger = getLogger ( 'crashMonitoring' )
26
+
25
27
/**
26
28
* Handles crash reporting for the extension.
27
29
*
@@ -97,7 +99,7 @@ export class CrashMonitoring {
97
99
try {
98
100
this . #didTryCreate = true
99
101
const isDevMode = getIsDevMode ( )
100
- const devModeLogger : Logger | undefined = isDevMode ? getLogger ( ) : undefined
102
+ const devModeLogger : Logger | undefined = isDevMode ? logger : undefined
101
103
const state = await crashMonitoringStateFactory ( ) // can throw
102
104
return ( this . #instance ??= new CrashMonitoring (
103
105
state ,
@@ -238,7 +240,7 @@ class CrashChecker {
238
240
239
241
public async start ( ) {
240
242
{
241
- this . devLogger ?. debug ( `crashMonitoring: checkInterval ${ this . checkInterval } ` )
243
+ this . devLogger ?. debug ( `checkInterval ${ this . checkInterval } ` )
242
244
243
245
// do an initial check
244
246
await withFailCtx ( 'initialCrashCheck' , ( ) =>
@@ -253,7 +255,7 @@ class CrashChecker {
253
255
// Due to sleep+wake the heartbeat has not been sent consistently. Skip 1 crash check interval
254
256
// to allow for a new heartbeat to be sent
255
257
if ( this . timeLag . didLag ( ) ) {
256
- this . devLogger ?. warn ( 'crashMonitoring: LAG detected time lag and skipped a crash check' )
258
+ this . devLogger ?. warn ( 'LAG detected time lag and skipped a crash check' )
257
259
telemetry . function_call . emit ( {
258
260
className : className ,
259
261
functionName : 'timeLag' ,
@@ -301,7 +303,7 @@ class CrashChecker {
301
303
// Example is if I hit the red square in the debug menu, it is a non-graceful shutdown. But the regular
302
304
// 'x' button in the Debug IDE instance is a graceful shutdown.
303
305
if ( ext . isDebug ) {
304
- devLogger ?. debug ( `crashMonitoring: DEBUG instance crashed: %O` , ext )
306
+ devLogger ?. debug ( `DEBUG instance crashed: %O` , ext )
305
307
return
306
308
}
307
309
@@ -322,7 +324,7 @@ class CrashChecker {
322
324
// Sanity check: ENSURE THAT AFTER === ACTUAL or this implies that our data is out of sync
323
325
const afterActual = ( await state . getAllExts ( ) ) . map ( ( i ) => truncateUuid ( i . sessionId ) )
324
326
devLogger ?. debug (
325
- `crashMonitoring: CHECKED: Result of cleaning up crashed instances\nBEFORE: %O \nAFTER: %O \nACTUAL: %O` ,
327
+ `CHECKED: Result of cleaning up crashed instances\nBEFORE: %O \nAFTER: %O \nACTUAL: %O` ,
326
328
before ,
327
329
after ,
328
330
afterActual
@@ -408,7 +410,7 @@ function getDefaultDependencies(): MementoStateDependencies {
408
410
isStateStale : ( ) => isNewOsSession ( ) ,
409
411
sessionId : _getSessionId ( ) ,
410
412
isDevMode : getIsDevMode ( ) ,
411
- devLogger : getIsDevMode ( ) ? getLogger ( ) : undefined ,
413
+ devLogger : getIsDevMode ( ) ? logger : undefined ,
412
414
}
413
415
}
414
416
/**
@@ -437,8 +439,8 @@ export class FileSystemState {
437
439
constructor ( protected readonly deps : MementoStateDependencies ) {
438
440
this . stateDirPath = path . join ( this . deps . workDirPath , crashMonitoringDirName )
439
441
440
- this . deps . devLogger ?. debug ( `crashMonitoring: sessionId: ${ this . deps . sessionId . slice ( 0 , 8 ) } -...` )
441
- this . deps . devLogger ?. debug ( `crashMonitoring: dir: ${ this . stateDirPath } ` )
442
+ this . deps . devLogger ?. debug ( `sessionId: ${ this . deps . sessionId . slice ( 0 , 8 ) } -...` )
443
+ this . deps . devLogger ?. debug ( `dir: ${ this . stateDirPath } ` )
442
444
}
443
445
444
446
/**
@@ -484,7 +486,7 @@ export class FileSystemState {
484
486
throw new CrashMonitoringError ( 'Heartbeat write validation failed' , { code : className } )
485
487
}
486
488
487
- this . deps . devLogger ?. debug ( `crashMonitoring: HEARTBEAT sent for ${ truncateUuid ( this . ext . sessionId ) } ` )
489
+ this . deps . devLogger ?. debug ( `HEARTBEAT sent for ${ truncateUuid ( this . ext . sessionId ) } ` )
488
490
}
489
491
const funcWithCtx = ( ) => withFailCtx ( 'sendHeartbeatState' , func )
490
492
const funcWithRetries = withRetries ( funcWithCtx , { maxRetries : 6 , delay : 100 , backoff : 2 } )
@@ -571,10 +573,10 @@ export class FileSystemState {
571
573
return path . join ( this . stateDirPath , extId + `.${ this . fileSuffix } ` )
572
574
}
573
575
public async clearState ( ) : Promise < void > {
574
- this . deps . devLogger ?. debug ( 'crashMonitoring: CLEAR_STATE: Started' )
576
+ this . deps . devLogger ?. debug ( 'CLEAR_STATE: Started' )
575
577
await withFailCtx ( 'clearState' , async ( ) => {
576
578
await nodeFs . rm ( this . stateDirPath , { force : true , recursive : true } )
577
- this . deps . devLogger ?. debug ( 'crashMonitoring: CLEAR_STATE: Succeeded' )
579
+ this . deps . devLogger ?. debug ( 'CLEAR_STATE: Succeeded' )
578
580
} )
579
581
}
580
582
public async getAllExts ( ) : Promise < ExtInstanceHeartbeat [ ] > {
0 commit comments