@@ -28,6 +28,9 @@ public static void Startup(this ExceptionlessClient client, string apiKey = null
2828 if ( client . Configuration . UpdateSettingsWhenIdleInterval == null )
2929 client . Configuration . UpdateSettingsWhenIdleInterval = TimeSpan . FromMinutes ( 2 ) ;
3030
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+
3134 client . RegisterAppDomainUnhandledExceptionHandler ( ) ;
3235
3336 // 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
3639
3740 if ( client . Configuration . SessionsEnabled )
3841 client . SubmitSessionStart ( ) ;
42+
43+ log . Info ( typeof ( ExceptionlessClient ) , "Startup finished" ) ;
3944 }
4045
4146 /// <summary>
@@ -46,13 +51,21 @@ public static async Task ShutdownAsync(this ExceptionlessClient client) {
4651 if ( client == null )
4752 throw new ArgumentNullException ( nameof ( client ) ) ;
4853
54+ var log = client . Configuration . Resolver . GetLog ( ) ;
55+ log . Info ( typeof ( ExceptionlessClient ) , "Shutdown called" ) ;
56+
4957 client . UnregisterAppDomainUnhandledExceptionHandler ( ) ;
5058 client . UnregisterOnProcessExitHandler ( ) ;
5159 client . UnregisterTaskSchedulerUnobservedTaskExceptionHandler ( ) ;
5260
5361 await client . ProcessQueueAsync ( ) . ConfigureAwait ( false ) ;
54- if ( client . Configuration . SessionsEnabled )
62+ if ( client . Configuration . SessionsEnabled ) {
63+ log . Info ( typeof ( ExceptionlessClient ) , "Sending Session End Heartbeat" ) ;
5564 await client . SubmitSessionEndAsync ( ) . ConfigureAwait ( false ) ;
65+ }
66+
67+ log . Info ( typeof ( ExceptionlessClient ) , "Shutdown finished" ) ;
68+ log . Flush ( ) ;
5669 }
5770
5871#region Submission Extensions
@@ -348,25 +361,32 @@ public static void RegisterAppDomainUnhandledExceptionHandler(this Exceptionless
348361 throw new ArgumentNullException ( nameof ( client ) ) ;
349362
350363 if ( _onAppDomainUnhandledException == null ) {
351- _onAppDomainUnhandledException = async ( sender , args ) => {
364+ _onAppDomainUnhandledException = ( sender , args ) => {
352365 var exception = args . ExceptionObject as Exception ;
353366 if ( exception == null )
354367 return ;
355368
369+ var log = client . Configuration . Resolver . GetLog ( ) ;
356370 try {
371+ log . Info ( typeof ( ExceptionlessClient ) , "AppDomain.CurrentDomain.UnhandledException called" ) ;
372+
357373 var contextData = new ContextData ( ) ;
358374 contextData . MarkAsUnhandledError ( ) ;
359375 contextData . SetSubmissionMethod ( "AppDomainUnhandledException" ) ;
360376
361377 exception . ToExceptionless ( contextData , client ) . Submit ( ) ;
362378
363379 // 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+ }
365386
366- if ( client . Configuration . SessionsEnabled )
367- await client . SubmitSessionEndAsync ( ) . ConfigureAwait ( false ) ;
387+ log . Info ( typeof ( ExceptionlessClient ) , "AppDomain.CurrentDomain.UnhandledException finished" ) ;
388+ log . Flush ( ) ;
368389 } catch ( Exception ex ) {
369- var log = client . Configuration . Resolver . GetLog ( ) ;
370390 log . Error ( typeof ( ExceptionlessClientExtensions ) , ex , String . Concat ( "An error occurred while processing AppDomain unhandled exception: " , ex . Message ) ) ;
371391 }
372392 } ;
@@ -397,14 +417,21 @@ public static void RegisterOnProcessExitHandler(this ExceptionlessClient client)
397417 throw new ArgumentNullException ( nameof ( client ) ) ;
398418
399419 if ( _onProcessExit == null ) {
400- _onProcessExit = async ( sender , args ) => {
420+ _onProcessExit = ( sender , args ) => {
421+ var log = client . Configuration . Resolver . GetLog ( ) ;
401422 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+ }
403431
404- if ( client . Configuration . SessionsEnabled )
405- await client . SubmitSessionEndAsync ( ) . ConfigureAwait ( false ) ;
432+ log . Info ( typeof ( ExceptionlessClient ) , "ProcessExit finished" ) ;
433+ log . Flush ( ) ;
406434 } catch ( Exception ex ) {
407- var log = client . Configuration . Resolver . GetLog ( ) ;
408435 log . Error ( typeof ( ExceptionlessClientExtensions ) , ex , String . Concat ( "An error occurred while processing process exit: " , ex . Message ) ) ;
409436 }
410437 } ;
0 commit comments