Flush logs before exiting the app.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-02-14 11:05:59 -05:00
parent 8da1e1399c
commit 49ba0ff942
4 changed files with 26 additions and 1 deletions

View File

@ -52,6 +52,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
- (void)applicationDidEnterBackground:(UIApplication *)application {
DDLogWarn(@"%@ applicationDidEnterBackground.", self.tag);
[DDLog flushLog];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
@ -68,6 +70,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
- (void)applicationWillTerminate:(UIApplication *)application
{
DDLogWarn(@"%@ applicationWillTerminate.", self.tag);
[DDLog flushLog];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
@ -312,6 +316,8 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
[DDLog flushLog];
}
- (void)application:(UIApplication *)application
@ -543,6 +549,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
if (![TSStorageManager isDatabasePasswordAccessible]) {
DDLogInfo(@"%@ exiting because we are in the background and the database password is not accessible.", self.tag);
[DDLog flushLog];
exit(0);
}
}

View File

@ -159,7 +159,8 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ADDRESSBOOK_RESTRICTED_ALERT_BUTTON", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
exit(0);
[DDLog flushLog];
exit(0);
}]];
[[UIApplication sharedApplication]

View File

@ -312,10 +312,26 @@ static Environment *environment = nil;
}
+ (void)resetAppData {
// This _should_ be wiped out below.
DDLogError(@"%@ %s", self.tag, __PRETTY_FUNCTION__);
[DDLog flushLog];
[[TSStorageManager sharedManager] resetSignalStorage];
[Environment.preferences clear];
[DebugLogger.sharedLogger wipeLogs];
exit(0);
}
#pragma mark - Logging
+ (NSString *)tag
{
return [NSString stringWithFormat:@"[%@]", self.class];
}
- (NSString *)tag
{
return self.class.tag;
}
@end

View File

@ -59,6 +59,7 @@
UIAlertAction *quitAction = [UIAlertAction actionWithTitle:@"Quit"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[DDLog flushLog];
exit(0);
}];
[alertController addAction:quitAction];