Start logging earlier in app setup.

Because logging-preference was previously stored on the storageManager
this meant we couldn't possible log anything related to the init'ing the
storage manager.

TODO: migrate old logging preference to use the new NSUserDefaults
setting

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent d9cfb38854
commit 870fb960a2

@ -58,14 +58,27 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initializing logger
CategorizingLogger *logger = [CategorizingLogger categorizingLogger];
[logger addLoggingCallback:^(NSString *category, id details, NSUInteger index){
}];
BOOL loggingIsEnabled;
#ifdef DEBUG
// Specified at Product -> Scheme -> Edit Scheme -> Test -> Arguments -> Environment to avoid things like
// the phone directory being looked up during tests.
loggingIsEnabled = TRUE;
[DebugLogger.sharedLogger enableTTYLogging];
#elif RELEASE
loggingIsEnabled = Environment.preferences.loggingIsEnabled;
#endif
if (loggingIsEnabled) {
[DebugLogger.sharedLogger enableFileLogging];
}
// XXX - careful when moving this. It must happen before we initialize TSStorageManager.
[self verifyDBKeysAvailableBeforeBackgroundLaunch];
// Initializing env logger
CategorizingLogger *logger = [CategorizingLogger categorizingLogger];
[logger addLoggingCallback:^(NSString *category, id details, NSUInteger index){
}];
// Setting up environment
[Environment setCurrent:[Release releaseEnvironmentWithLogging:logger]];
@ -81,21 +94,6 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
}
[Environment.getCurrent initCallListener];
BOOL loggingIsEnabled;
#ifdef DEBUG
// Specified at Product -> Scheme -> Edit Scheme -> Test -> Arguments -> Environment to avoid things like
// the phone directory being looked up during tests.
loggingIsEnabled = TRUE;
[DebugLogger.sharedLogger enableTTYLogging];
#elif RELEASE
loggingIsEnabled = Environment.preferences.loggingIsEnabled;
#endif
if (loggingIsEnabled) {
[DebugLogger.sharedLogger enableFileLogging];
}
[self setupTSKitEnv];
UIStoryboard *storyboard;

@ -68,16 +68,6 @@ NSString *const PropertyListPreferencesKeyLastRecordedVoipToken = @"LastRecorded
[self setValueForKey:PropertyListPreferencesKeyCallStreamDESBufferLevel toValue:@(value)];
}
- (BOOL)loggingIsEnabled
{
NSNumber *preference = [self tryGetValueForKey:PropertyListPreferencesKeyEnableDebugLog];
if (preference) {
return [preference boolValue];
} else {
return YES;
}
}
- (BOOL)screenSecurityIsEnabled
{
NSNumber *preference = [self tryGetValueForKey:PropertyListPreferencesKeyScreenSecurity];
@ -130,9 +120,21 @@ NSString *const PropertyListPreferencesKeyLastRecordedVoipToken = @"LastRecorded
[self setValueForKey:PropertyListPreferencesKeyHasRegisteredVoipPush toValue:@(enabled)];
}
- (BOOL)loggingIsEnabled
{
NSNumber *preference = [NSUserDefaults.standardUserDefaults objectForKey:PropertyListPreferencesKeyEnableDebugLog];
if (preference) {
return [preference boolValue];
} else {
return YES;
}
}
- (void)setLoggingEnabled:(BOOL)flag
{
[self setValueForKey:PropertyListPreferencesKeyEnableDebugLog toValue:@(flag)];
[NSUserDefaults.standardUserDefaults setObject:@(flag) forKey:PropertyListPreferencesKeyEnableDebugLog];
[NSUserDefaults.standardUserDefaults synchronize];
}
- (nullable NSString *)lastRanVersion

Loading…
Cancel
Save