Skip to content

Commit 5c6d170

Browse files
committed
Update some log messages
1 parent bd9cde7 commit 5c6d170

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

Sources/BranchSDK/BNCNetworkInterface.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ - (NSString*) description {
4141
];
4242
}
4343

44+
// Reads network interface information to the device IP address
4445
+ (NSArray<BNCNetworkInterface *> *)currentInterfaces {
4546

4647
struct ifaddrs *interfaces = NULL;
@@ -49,8 +50,11 @@ - (NSString*) description {
4950
// Retrieve the current interfaces - returns 0 on success
5051
if (getifaddrs(&interfaces) != 0) {
5152
int e = errno;
52-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Can't read ip address: (%d): %s.", e, strerror(e)] error:nil];
53-
goto exit;
53+
[[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Failed to read IP Address: (%d): %s", e, strerror(e)] error:nil];
54+
55+
// Error handling in C code is one case where goto can improve readability.
56+
// https://www.kernel.org/doc/html/v4.19/process/coding-style.html
57+
goto err_free_interfaces;
5458
}
5559

5660
// Loop through linked list of interfaces --
@@ -92,7 +96,7 @@ - (NSString*) description {
9296
}
9397
}
9498

95-
exit:
99+
err_free_interfaces:
96100
if (interfaces) freeifaddrs(interfaces);
97101
return currentInterfaces;
98102
}

Sources/BranchSDK/BNCReferringURLUtility.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ - (void)processQueryParameter:(NSURLQueryItem *)item {
7979
param.validityWindow = [self defaultValidityWindowForParam:name];
8080
}
8181

82+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Parsed Referring URL: %@", param] error:nil];
8283
[self.urlQueryParameters setValue:param forKey:name];
8384
}
8485

@@ -90,6 +91,8 @@ - (void)processMetaQueryParameter:(NSURLQueryItem *)item {
9091
param.timestamp = [NSDate date];
9192
param.isDeepLink = YES;
9293
param.validityWindow = [self defaultValidityWindowForParam:BRANCH_REQUEST_KEY_META_CAMPAIGN_IDS];
94+
95+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Parsed Referring URL: %@", param] error:nil];
9396
[self.urlQueryParameters setValue:param forKey:BRANCH_REQUEST_KEY_META_CAMPAIGN_IDS];
9497
}
9598
}
@@ -112,6 +115,8 @@ - (NSDictionary *)dictionaryFromEncodedJsonString:(NSString *)encodedJsonString
112115
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
113116
if (!error) {
114117
return json;
118+
} else {
119+
[[BranchLogger shared] logError:@"Failed to parse Meta AEM JSON" error:error];
115120
}
116121
}
117122
return nil;
@@ -263,7 +268,6 @@ - (NSMutableDictionary *)serializeToJson:(NSMutableDictionary<NSString *, BNCUrl
263268
}
264269

265270
- (void)checkForAndMigrateOldGbraid {
266-
267271
if (self.preferenceHelper.referrerGBRAID != nil &&
268272
self.urlQueryParameters[BRANCH_REQUEST_KEY_REFERRER_GBRAID].value == nil) {
269273

@@ -286,7 +290,7 @@ - (void)checkForAndMigrateOldGbraid {
286290
self.preferenceHelper.referrerGBRAIDValidityWindow = 0;
287291
self.preferenceHelper.referrerGBRAIDInitDate = nil;
288292

289-
[[BranchLogger shared] logDebug:@"Updated old Gbraid to new BNCUrlQueryParameter" error:nil];
293+
[[BranchLogger shared] logVerbose:@"Migrated old Gbraid to a BNCUrlQueryParameter" error:nil];
290294
}
291295
}
292296

Sources/BranchSDK/BNCSystemObserver.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ @implementation BNCSystemObserver
3131
+ (NSString *)appleAttributionToken {
3232
// token is not available on simulator
3333
if ([self isSimulator]) {
34+
[[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"AppleAttributionToken not available on simulator"] error:nil];
3435
return nil;
3536
}
3637

@@ -54,7 +55,7 @@ + (NSString *)appleAttributionToken {
5455
// Apple said this API should respond within 50ms, lets give up after 500 ms
5556
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(500 * NSEC_PER_MSEC)));
5657
if (token == nil) {
57-
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"AppleAttributionToken request timed out"] error:nil];
58+
[[BranchLogger shared] logError:[NSString stringWithFormat:@"AppleAttributionToken request timed out"] error:nil];
5859
}
5960
}
6061
#endif
@@ -64,6 +65,7 @@ + (NSString *)appleAttributionToken {
6465

6566
+ (NSString *)advertiserIdentifier {
6667
#ifdef BRANCH_EXCLUDE_IDFA_CODE
68+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BRANCH_EXCLUDE_IDFA_CODE flag enabled. IDFA is not available"] error:nil];
6769
return nil;
6870

6971
#else
@@ -80,6 +82,7 @@ + (NSString *)advertiserIdentifier {
8082
(sharedManager, advertisingIdentifierSelector);
8183
uid = [uuid UUIDString];
8284
if ([uid isEqualToString:@"00000000-0000-0000-0000-000000000000"]) {
85+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"IDFA is all 0's. Probably running on a simulator or an App Clip."] error:nil];
8386
uid = nil;
8487
}
8588
}
@@ -92,6 +95,7 @@ + (NSString *)attOptedInStatus {
9295
NSString *statusString = @"unavailable";
9396

9497
#ifdef BRANCH_EXCLUDE_ATT_STATUS_CODE
98+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BRANCH_EXCLUDE_IDFA_CODE flag enabled. ATT opt in status unavailable"] error:nil];
9599
#else
96100

97101
Class ATTrackingManagerClass = NSClassFromString(@"ATTrackingManager");
@@ -128,6 +132,8 @@ + (NSString *)defaultURIScheme {
128132
for (NSDictionary *urlType in urlTypes) {
129133
NSArray *urlSchemes = [urlType objectForKey:@"CFBundleURLSchemes"];
130134
for (NSString *uriScheme in urlSchemes) {
135+
136+
// TODO: Add a log to indicate that a URI was ignored due to a match with a known URI format
131137
if ([uriScheme hasPrefix:@"fb"]) continue; // Facebook
132138
if ([uriScheme hasPrefix:@"db"]) continue; // DB?
133139
if ([uriScheme hasPrefix:@"twitterkit-"]) continue; // Twitter
@@ -151,6 +157,8 @@ + (NSString *)teamIdentifier {
151157
if (teamWithDot.length) {
152158
return [teamWithDot substringToIndex:([teamWithDot length] - 1)];
153159
}
160+
161+
[[BranchLogger shared] logVerbose:@"AppIdentifierPrefix not found in mainBundle" error:nil];
154162
return nil;
155163
}
156164

Sources/BranchSDK/BNCURLFilter.m

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ - (void)useDefaultPatternList {
5858
if (regex && !regexError) {
5959
[array addObject:regex];
6060
} else {
61-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Invalid regular expression '%@': %@.", pattern, regexError] error:regexError];
61+
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Invalid regular expression '%@'", pattern] error:regexError];
6262
}
6363
}
6464
return array;
@@ -129,13 +129,9 @@ - (BOOL)foundUpdatedURLList:(id<BNCNetworkOperationProtocol>)operation {
129129
if (statusCode == 404) {
130130
[[BranchLogger shared] logDebug:@"No update for URL ignore list found." error:nil];
131131
return NO;
132-
133132
} else if (statusCode != 200 || error != nil || jsonString == nil) {
134-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Failed to update URL ignore list. error: %@ status: %ld", operation.error, (long)operation.response.statusCode] error:operation.error];
135-
[[BranchLogger shared] logDebug: [NSString stringWithFormat:@"URL ignore JSON: %@", jsonString] error:nil];
136-
133+
[[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Failed to update URL ignore list. error: %@ status: %ld", operation.error, (long)operation.response.statusCode] error:operation.error];
137134
return NO;
138-
139135
} else {
140136
return YES;
141137
}
@@ -146,19 +142,19 @@ - (nullable NSDictionary *)parseJSONFromData:(NSData *)data {
146142
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
147143

148144
if (error) {
149-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Can't parse URL ignore JSON: %@.", error] error:error];
145+
[[BranchLogger shared] logError:@"Failed to parse uri_skip_list" error:error];
150146
return nil;
151147
}
152148

153149
NSArray *urls = dictionary[@"uri_skip_list"];
154150
if (![urls isKindOfClass:NSArray.class]) {
155-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Can't parse URL ignore JSON, uri_skip_list is not a NSArray."] error:nil];
151+
[[BranchLogger shared] logError:@"Failed to parse uri_skip_list is not a NSArray" error:nil];
156152
return nil;
157153
}
158154

159155
NSNumber *version = dictionary[@"version"];
160156
if (![version isKindOfClass:NSNumber.class]) {
161-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Can't parse URL ignore JSON, version is not a NSNumber."] error:nil];
157+
[[BranchLogger shared] logError:@"Failed to parse uri_skip_list, version is not a NSNumber." error:nil];
162158
return nil;
163159
}
164160

Sources/BranchSDK/BranchJsonConfig.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ - (void)loadConfigFile
5656
NSError *error;
5757
id object = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
5858
if (!object || error) {
59-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Failed to parse branch.json. Error: %@", error.localizedDescription] error:error];
59+
[[BranchLogger shared] logError:@"Failed to parse branch.json" error:error];
6060
return;
6161
}
6262

6363
if (![object isKindOfClass:NSDictionary.class]) {
6464
[[BranchLogger shared] logError:@"Contents of branch.json should be a JSON object." error:nil];
65-
6665
return;
6766
}
6867

@@ -72,11 +71,10 @@ - (void)loadConfigFile
7271
- (NSData *)configFileContents
7372
{
7473
if (!self.configFileURL) return nil;
75-
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Loading %@", self.configFileURL.pathComponents.lastObject] error:nil];
7674
NSError *error;
7775
NSData *data = [NSData dataWithContentsOfURL:self.configFileURL options:0 error:&error];
7876
if (!data || error) {
79-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Failed to load %@. Error: %@", self.configFileURL, error.localizedDescription] error:error];
77+
[[BranchLogger shared] logError:@"Failed to load branch.json" error:error];
8078
return nil;
8179
}
8280
return data;
@@ -109,7 +107,7 @@ - (void)findConfigFile
109107
}
110108

111109
if (!configFileURL) {
112-
[[BranchLogger shared] logDebug:@"No branch.json in app bundle." error:nil];
110+
[[BranchLogger shared] logDebug:@"No branch.json in app bundle" error:nil];
113111
return;
114112
}
115113

Sources/BranchSDK/BranchLastAttributedTouchData.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ + (void)requestLastTouchAttributedData:(BNCServerInterface *)serverInterface key
3333
if (window > -1 && window < 365) {
3434
request.attributionWindow = window;
3535
} else {
36-
[[BranchLogger shared] logWarning:@"Attribution window is outside the expected range, using 30 days." error:nil];
36+
[[BranchLogger shared] logWarning:@"Attribution window is outside the expected range, using 30 days" error:nil];
3737
}
3838

3939
[request makeRequest:serverInterface key:key callback:^(BNCServerResponse *response, NSError *error) {

0 commit comments

Comments
 (0)