|
40 | 40 | #import "NSMutableDictionary+Branch.h" |
41 | 41 | #import "BNCNetworkService.h" |
42 | 42 | #import "BNCLog.h" |
| 43 | +#import "NSString+Branch.h" |
43 | 44 | #import "BNCFabricAnswers.h" |
44 | 45 | #import "../Fabric/FABKitProtocol.h" // Fabric |
45 | 46 |
|
|
77 | 78 |
|
78 | 79 | void ForceCategoriesToLoad(void); |
79 | 80 | void ForceCategoriesToLoad(void) { |
80 | | - ForceNSMutableDictionaryToLoad(); |
| 81 | + BNCForceNSErrorCategoryToLoad(); |
| 82 | + BNCForceNSStringCategoryToLoad(); |
| 83 | + BNCForceNSMutableDictionaryCategoryToLoad(); |
81 | 84 | } |
82 | 85 |
|
83 | 86 |
|
@@ -125,15 +128,23 @@ + (void) load { |
125 | 128 | [self openLog]; |
126 | 129 | } |
127 | 130 |
|
| 131 | +static NSURL* bnc_logURL = nil; |
| 132 | + |
128 | 133 | + (void) openLog { |
129 | 134 | // Initialize the log |
130 | | - BNCLogInitialize(); |
131 | | - BNCLogSetDisplayLevel(BNCLogLevelAll); |
132 | | - NSURL *logURL = BNCURLForBranchDirectory(); |
133 | | - logURL = [logURL URLByAppendingPathComponent:@"Branch.log"]; |
134 | | - BNCLogSetOutputToURLByteWrap(logURL, 102400); |
135 | | - BNCLogSetDisplayLevel(BNCLogLevelWarning); |
136 | | - BNCLogDebug(@"Branch version %@ started at %@.", BNC_SDK_VERSION, [NSDate date]); |
| 135 | + @synchronized (self) { |
| 136 | + if (!bnc_logURL) { |
| 137 | + BNCLogInitialize(); |
| 138 | + BNCLogSetDisplayLevel(BNCLogLevelAll); |
| 139 | + bnc_logURL = BNCURLForBranchDirectory(); |
| 140 | + bnc_logURL = [bnc_logURL URLByAppendingPathComponent:@"Branch.log"]; |
| 141 | + BNCLogSetOutputToURLByteWrap(bnc_logURL, 102400); |
| 142 | + BNCLogSetDisplayLevel(BNCLogLevelWarning); |
| 143 | + BNCLogDebug(@"Branch version %@ started at %@.", BNC_SDK_VERSION, [NSDate date]); |
| 144 | + } else { |
| 145 | + BNCLogSetOutputToURLByteWrap(bnc_logURL, 102400); |
| 146 | + } |
| 147 | + } |
137 | 148 | } |
138 | 149 |
|
139 | 150 | + (void) closeLog { |
@@ -365,7 +376,8 @@ + (BOOL) enableFingerprintIDInCrashlyticsReports |
365 | 376 |
|
366 | 377 | - (void)setDebug { |
367 | 378 | self.preferenceHelper.isDebug = YES; |
368 | | - BNCLogSetDisplayLevel(BNCLogLevelDebug); |
| 379 | + if (BNCLogDisplayLevel() > BNCLogLevelDebug) |
| 380 | + BNCLogSetDisplayLevel(BNCLogLevelDebug); |
369 | 381 | } |
370 | 382 |
|
371 | 383 | - (void)resetUserSession { |
@@ -1652,6 +1664,8 @@ - (void) processRequest:(BNCServerRequest*)req |
1652 | 1664 | } |
1653 | 1665 | // On network problems, or Branch down, call the other callbacks and stop processing. |
1654 | 1666 | else { |
| 1667 | + BNCLogDebugSDK(@"Network error: failing queued requests."); |
| 1668 | + |
1655 | 1669 | // First, gather all the requests to fail |
1656 | 1670 | NSMutableArray *requestsToFail = [[NSMutableArray alloc] init]; |
1657 | 1671 | for (int i = 0; i < self.requestQueue.queueDepth; i++) { |
@@ -1727,7 +1741,9 @@ - (void)processNextQueueItem { |
1727 | 1741 | #pragma mark - Session Initialization |
1728 | 1742 |
|
1729 | 1743 | - (void)initSessionIfNeededAndNotInProgress { |
1730 | | - if (!self.isInitialized && !self.preferenceHelper.shouldWaitForInit && ![self.requestQueue containsInstallOrOpen]) { |
| 1744 | + if (!self.isInitialized && |
| 1745 | + !self.preferenceHelper.shouldWaitForInit && |
| 1746 | + ![self.requestQueue containsInstallOrOpen]) { |
1731 | 1747 | [self initUserSessionAndCallCallback:NO]; |
1732 | 1748 | } |
1733 | 1749 | } |
|
0 commit comments