@@ -28,6 +28,9 @@ public static void Startup(this ExceptionlessClient client, string apiKey = null
28
28
if ( client . Configuration . UpdateSettingsWhenIdleInterval == null )
29
29
client . Configuration . UpdateSettingsWhenIdleInterval = TimeSpan . FromMinutes ( 2 ) ;
30
30
31
+ var log = client . Configuration . Resolver . GetLog ( ) ;
32
+ log . FormattedInfo ( typeof ( ExceptionlessClient ) , "Startup called ApiKey={0} ServerUrl={1}" , client . Configuration . ApiKey , client . Configuration . ServerUrl ) ;
33
+
31
34
client . RegisterAppDomainUnhandledExceptionHandler ( ) ;
32
35
33
36
// make sure that queued events are sent when the app exits
@@ -36,6 +39,8 @@ public static void Startup(this ExceptionlessClient client, string apiKey = null
36
39
37
40
if ( client . Configuration . SessionsEnabled )
38
41
client . SubmitSessionStart ( ) ;
42
+
43
+ log . Info ( typeof ( ExceptionlessClient ) , "Startup finished" ) ;
39
44
}
40
45
41
46
/// <summary>
@@ -46,13 +51,21 @@ public static async Task ShutdownAsync(this ExceptionlessClient client) {
46
51
if ( client == null )
47
52
throw new ArgumentNullException ( nameof ( client ) ) ;
48
53
54
+ var log = client . Configuration . Resolver . GetLog ( ) ;
55
+ log . Info ( typeof ( ExceptionlessClient ) , "Shutdown called" ) ;
56
+
49
57
client . UnregisterAppDomainUnhandledExceptionHandler ( ) ;
50
58
client . UnregisterOnProcessExitHandler ( ) ;
51
59
client . UnregisterTaskSchedulerUnobservedTaskExceptionHandler ( ) ;
52
60
53
61
await client . ProcessQueueAsync ( ) . ConfigureAwait ( false ) ;
54
- if ( client . Configuration . SessionsEnabled )
62
+ if ( client . Configuration . SessionsEnabled ) {
63
+ log . Info ( typeof ( ExceptionlessClient ) , "Sending Session End Heartbeat" ) ;
55
64
await client . SubmitSessionEndAsync ( ) . ConfigureAwait ( false ) ;
65
+ }
66
+
67
+ log . Info ( typeof ( ExceptionlessClient ) , "Shutdown finished" ) ;
68
+ log . Flush ( ) ;
56
69
}
57
70
58
71
#region Submission Extensions
@@ -348,25 +361,32 @@ public static void RegisterAppDomainUnhandledExceptionHandler(this Exceptionless
348
361
throw new ArgumentNullException ( nameof ( client ) ) ;
349
362
350
363
if ( _onAppDomainUnhandledException == null ) {
351
- _onAppDomainUnhandledException = async ( sender , args ) => {
364
+ _onAppDomainUnhandledException = ( sender , args ) => {
352
365
var exception = args . ExceptionObject as Exception ;
353
366
if ( exception == null )
354
367
return ;
355
368
369
+ var log = client . Configuration . Resolver . GetLog ( ) ;
356
370
try {
371
+ log . Info ( typeof ( ExceptionlessClient ) , "AppDomain.CurrentDomain.UnhandledException called" ) ;
372
+
357
373
var contextData = new ContextData ( ) ;
358
374
contextData . MarkAsUnhandledError ( ) ;
359
375
contextData . SetSubmissionMethod ( "AppDomainUnhandledException" ) ;
360
376
361
377
exception . ToExceptionless ( contextData , client ) . Submit ( ) ;
362
378
363
379
// process queue immediately since the app is about to exit.
364
- await client . ProcessQueueAsync ( ) . ConfigureAwait ( false ) ;
380
+ client . ProcessQueueAsync ( ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
381
+
382
+ if ( client . Configuration . SessionsEnabled ) {
383
+ log . Info ( typeof ( ExceptionlessClient ) , "Sending Session End Heartbeat" ) ;
384
+ client . SubmitSessionEndAsync ( ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
385
+ }
365
386
366
- if ( client . Configuration . SessionsEnabled )
367
- await client . SubmitSessionEndAsync ( ) . ConfigureAwait ( false ) ;
387
+ log . Info ( typeof ( ExceptionlessClient ) , "AppDomain.CurrentDomain.UnhandledException finished" ) ;
388
+ log . Flush ( ) ;
368
389
} catch ( Exception ex ) {
369
- var log = client . Configuration . Resolver . GetLog ( ) ;
370
390
log . Error ( typeof ( ExceptionlessClientExtensions ) , ex , String . Concat ( "An error occurred while processing AppDomain unhandled exception: " , ex . Message ) ) ;
371
391
}
372
392
} ;
@@ -397,14 +417,21 @@ public static void RegisterOnProcessExitHandler(this ExceptionlessClient client)
397
417
throw new ArgumentNullException ( nameof ( client ) ) ;
398
418
399
419
if ( _onProcessExit == null ) {
400
- _onProcessExit = async ( sender , args ) => {
420
+ _onProcessExit = ( sender , args ) => {
421
+ var log = client . Configuration . Resolver . GetLog ( ) ;
401
422
try {
402
- await client . ProcessQueueAsync ( ) . ConfigureAwait ( false ) ;
423
+ log . Info ( typeof ( ExceptionlessClient ) , "ProcessExit called" ) ;
424
+
425
+ client . ProcessQueueAsync ( ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
426
+
427
+ if ( client . Configuration . SessionsEnabled ) {
428
+ log . Info ( typeof ( ExceptionlessClient ) , "Sending Session End Heartbeat" ) ;
429
+ client . SubmitSessionEndAsync ( ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
430
+ }
403
431
404
- if ( client . Configuration . SessionsEnabled )
405
- await client . SubmitSessionEndAsync ( ) . ConfigureAwait ( false ) ;
432
+ log . Info ( typeof ( ExceptionlessClient ) , "ProcessExit finished" ) ;
433
+ log . Flush ( ) ;
406
434
} catch ( Exception ex ) {
407
- var log = client . Configuration . Resolver . GetLog ( ) ;
408
435
log . Error ( typeof ( ExceptionlessClientExtensions ) , ex , String . Concat ( "An error occurred while processing process exit: " , ex . Message ) ) ;
409
436
}
410
437
} ;
0 commit comments