Skip to content

Commit

Permalink
[iOS] disable logging to application console in production (#1310)
Browse files Browse the repository at this point in the history
* feat: replace NSLog statements with DLog statements

* Ignore me

Testing CI trigger
  • Loading branch information
hakonk authored and Salakar committed Sep 7, 2018
1 parent 97f6998 commit a506d1e
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# editorconfig.org
# editorconfig
root = true

[*]
Expand Down
2 changes: 1 addition & 1 deletion ios/RNFirebase/RNFirebase.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ @implementation RNFirebase
- (id)init {
self = [super init];
if (self != nil) {
NSLog(@"Setting up RNFirebase instance");
DLog(@"Setting up RNFirebase instance");
}
return self;
}
Expand Down
6 changes: 6 additions & 0 deletions ios/RNFirebase/RNFirebaseUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#import <React/RCTEventEmitter.h>
#import <Firebase.h>

#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif

@interface RNFirebaseUtil : NSObject

+ (FIRApp *)getApp:(NSString *)appDisplayName;
Expand Down
2 changes: 1 addition & 1 deletion ios/RNFirebase/RNFirebaseUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ + (void)sendJSEvent:(RCTEventEmitter *)emitter name:(NSString *)name body:(id)bo
[emitter sendEventWithName:name body:body];
}
} @catch (NSException *error) {
NSLog(@"An error occurred in sendJSEvent: %@", [error debugDescription]);
DLog(@"An error occurred in sendJSEvent: %@", [error debugDescription]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ios/RNFirebase/auth/RNFirebaseAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ -(void)createUserWithEmail:(NSString *)appDisplayName
[changeRequest setValue:props[key] forKey:key];
}
} @catch (NSException *exception) {
NSLog(@"Exception occurred while configuring: %@", exception);
DLog(@"Exception occurred while configuring: %@", exception);
}
}

Expand Down Expand Up @@ -1128,7 +1128,7 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider token:(NSSt
} else if ([provider compare:@"oauth" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
credential = [FIROAuthProvider credentialWithProviderID:@"oauth" IDToken:authToken accessToken:authTokenSecret];
} else {
NSLog(@"Provider not yet handled: %@", provider);
DLog(@"Provider not yet handled: %@", provider);
}

return credential;
Expand Down
2 changes: 1 addition & 1 deletion ios/RNFirebase/database/RNFirebaseDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (id)init {
});

if (!transactionState) {
NSLog(@"tryCommitTransaction for unknown ID %@", transactionId);
DLog(@"tryCommitTransaction for unknown ID %@", transactionId);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions ios/RNFirebase/database/RNFirebaseDatabaseReference.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ - (void)on:(NSString *)eventType registration:(NSDictionary *)registration {
[self handleDatabaseEvent:eventType registration:registration dataSnapshot:snapshot previousChildName:previousChildName];
};
id errorBlock = ^(NSError *_Nonnull error) {
NSLog(@"Error onDBEvent: %@", [error debugDescription]);
DLog(@"Error onDBEvent: %@", [error debugDescription]);
[self removeEventListener:eventRegistrationKey];
[self handleDatabaseError:registration error:error];
};
Expand All @@ -56,7 +56,7 @@ - (void)once:(NSString *)eventType
NSDictionary *data = [RNFirebaseDatabaseReference snapshotToDictionary:snapshot previousChildName:previousChildName];
resolve(data);
} withCancelBlock:^(NSError *_Nonnull error) {
NSLog(@"Error onDBEventOnce: %@", [error debugDescription]);
DLog(@"Error onDBEventOnce: %@", [error debugDescription]);
[RNFirebaseDatabase handlePromise:resolve rejecter:reject databaseError:error];
}];
}
Expand Down
6 changes: 3 additions & 3 deletions ios/RNFirebase/firestore/RNFirebaseFirestore.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ - (id)init {
});

if (!transactionState) {
NSLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
DLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
return;
}

Expand Down Expand Up @@ -77,7 +77,7 @@ - (id)init {
});

if (!transactionState) {
NSLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
DLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
return;
}

Expand All @@ -96,7 +96,7 @@ - (id)init {
});

if (!transactionState) {
NSLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
DLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
return;
}

Expand Down
8 changes: 4 additions & 4 deletions ios/RNFirebase/invites/RNFirebaseInvites.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ + (nonnull instancetype)instance {
- (id)init {
self = [super init];
if (self != nil) {
NSLog(@"Setting up RNFirebaseInvites instance");
DLog(@"Setting up RNFirebaseInvites instance");
// Set static instance for use from AppDelegate
theRNFirebaseInvites = self;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ - (void)inviteFinishedWithInvitations:(NSArray *)invitationIds error:(NSError *)
if (url) {
[FIRInvites handleUniversalLink:url completion:^(FIRReceivedInvite * _Nullable receivedInvite, NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to handle universal link: %@", [error localizedDescription]);
DLog(@"Failed to handle universal link: %@", [error localizedDescription]);
reject(@"invites/initial-invitation-error", @"Failed to handle invitation", error);
} else if (receivedInvite && receivedInvite.inviteId) {
resolve(@{
Expand Down Expand Up @@ -168,7 +168,7 @@ - (void)inviteFinishedWithInvitations:(NSArray *)invitationIds error:(NSError *)
- (BOOL)handleUrl:(NSURL *)url {
return [FIRInvites handleUniversalLink:url completion:^(FIRReceivedInvite * _Nullable receivedInvite, NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to handle invitation: %@", [error localizedDescription]);
DLog(@"Failed to handle invitation: %@", [error localizedDescription]);
} else if (receivedInvite && receivedInvite.inviteId) {
[self sendJSEvent:self name:INVITES_INVITATION_RECEIVED body:@{
@"deepLink": receivedInvite.deepLink,
Expand All @@ -188,7 +188,7 @@ - (void)sendJSEvent:(RCTEventEmitter *)emitter name:(NSString *)name body:(id)bo
} else if (!initialInvite) {
initialInvite = body;
} else {
NSLog(@"Multiple invite events received before the JS invites module has been initialised");
DLog(@"Multiple invite events received before the JS invites module has been initialised");
}
}

Expand Down
22 changes: 11 additions & 11 deletions ios/RNFirebase/links/RNFirebaseLinks.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ + (nonnull instancetype)instance {
- (id)init {
self = [super init];
if (self != nil) {
NSLog(@"Setting up RNFirebaseLinks instance");
DLog(@"Setting up RNFirebaseLinks instance");
// Set static instance for use from AppDelegate
theRNFirebaseLinks = self;
}
Expand Down Expand Up @@ -64,7 +64,7 @@ - (BOOL)application:(UIApplication *)application
NSURL* url = dynamicLink.url;
[self sendJSEvent:self name:LINKS_LINK_RECEIVED body:url.absoluteString];
} else {
NSLog(@"Failed to handle universal link: %@", userActivity.webpageURL);
DLog(@"Failed to handle universal link: %@", userActivity.webpageURL);
}
}];
}
Expand All @@ -89,12 +89,12 @@ - (void)sendLink:(NSString *)link {
reject(@"links/failure", @"Failed to create Dynamic Link", nil);
} else {
NSString *longLink = dynamicLink.url.absoluteString;
NSLog(@"created long dynamic link: %@", longLink);
DLog(@"created long dynamic link: %@", longLink);
resolve(longLink);
}
}
@catch(NSException * e) {
NSLog(@"create dynamic link failure %@", e);
DLog(@"create dynamic link failure %@", e);
reject(@"links/failure",[e reason], nil);
}
}
Expand All @@ -116,17 +116,17 @@ - (void)sendLink:(NSString *)link {
}
[components shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray *_Nullable warnings, NSError *_Nullable error) {
if (error) {
NSLog(@"create short dynamic link failure %@", [error localizedDescription]);
DLog(@"create short dynamic link failure %@", [error localizedDescription]);
reject(@"links/failure", @"Failed to create Short Dynamic Link", error);
} else {
NSString *shortLink = shortURL.absoluteString;
NSLog(@"created short dynamic link: %@", shortLink);
DLog(@"created short dynamic link: %@", shortLink);
resolve(shortLink);
}
}];
}
@catch(NSException * e) {
NSLog(@"create short dynamic link failure %@", e);
DLog(@"create short dynamic link failure %@", e);
reject(@"links/failure",[e reason], nil);
}
}
Expand All @@ -143,11 +143,11 @@ - (void)sendLink:(NSString *)link {
BOOL handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL
completion:^(FIRDynamicLink * _Nullable dynamicLink, NSError * _Nullable error) {
if (error != nil){
NSLog(@"Failed to handle universal link: %@", [error localizedDescription]);
DLog(@"Failed to handle universal link: %@", [error localizedDescription]);
reject(@"links/failure", @"Failed to handle universal link", error);
} else {
NSString* urlString = dynamicLink ? dynamicLink.url.absoluteString : userActivity.webpageURL.absoluteString;
NSLog(@"initial link is: %@", urlString);
DLog(@"initial link is: %@", urlString);
resolve(urlString);
}
}];
Expand All @@ -174,7 +174,7 @@ - (void)sendJSEvent:(RCTEventEmitter *)emitter name:(NSString *)name body:(id)bo
} else if (!initialLink) {
initialLink = body;
} else {
NSLog(@"Multiple link events received before the JS links module has been initialised");
DLog(@"Multiple link events received before the JS links module has been initialised");
}
}

Expand All @@ -193,7 +193,7 @@ - (FIRDynamicLinkComponents *)buildDynamicLink:(NSDictionary *)linkData {
return components;
}
@catch(NSException * e) {
NSLog(@"error while building componets from meta data %@", e);
DLog(@"error while building componets from meta data %@", e);
@throw;
}
}
Expand Down
6 changes: 3 additions & 3 deletions ios/RNFirebase/messaging/RNFirebaseMessaging.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ + (nonnull instancetype)instance {
- (id)init {
self = [super init];
if (self != nil) {
NSLog(@"Setting up RNFirebaseMessaging instance");
DLog(@"Setting up RNFirebaseMessaging instance");
[self configure];
}
return self;
Expand Down Expand Up @@ -84,7 +84,7 @@ - (void)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo {

// Listen for FCM tokens
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {
NSLog(@"Received new FCM token: %@", fcmToken);
DLog(@"Received new FCM token: %@", fcmToken);
[self sendJSEvent:self name:MESSAGING_TOKEN_REFRESHED body:fcmToken];
}

Expand Down Expand Up @@ -237,7 +237,7 @@ - (void)sendJSEvent:(RCTEventEmitter *)emitter name:(NSString *)name body:(id)bo
}
[pendingMessages addObject:body];
} else {
NSLog(@"Received unexpected message type");
DLog(@"Received unexpected message type");
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions ios/RNFirebase/notifications/RNFirebaseNotifications.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ + (void)configure {
- (id)init {
self = [super init];
if (self != nil) {
NSLog(@"Setting up RNFirebaseNotifications instance");
DLog(@"Setting up RNFirebaseNotifications instance");
[self initialise];
}
return self;
Expand Down Expand Up @@ -403,7 +403,7 @@ - (void)sendJSEvent:(RCTEventEmitter *)emitter name:(NSString *)name body:(id)bo
if ([name isEqualToString:NOTIFICATIONS_NOTIFICATION_OPENED] && !initialNotification) {
initialNotification = body;
} else if ([name isEqualToString:NOTIFICATIONS_NOTIFICATION_OPENED]) {
NSLog(@"Multiple notification open events received before the JS Notifications module has been initialised");
DLog(@"Multiple notification open events received before the JS Notifications module has been initialised");
}
// PRE-BRIDGE-EVENTS: Consider enabling this to allow events built up before the bridge is built to be sent to the JS side
// [pendingEvents addObject:@{@"name":name, @"body":body}];
Expand Down Expand Up @@ -525,7 +525,7 @@ - (UNNotificationRequest*) buildUNNotificationRequest:(NSDictionary *) notificat
if (attachment) {
[attachments addObject:attachment];
} else {
NSLog(@"Failed to create attachment: %@", error);
DLog(@"Failed to create attachment: %@", error);
}
}
content.attachments = attachments;
Expand Down Expand Up @@ -713,7 +713,7 @@ - (NSDictionary*)parseUserInfo:(NSDictionary *)userInfo {
|| [k3 isEqualToString:@"title-loc-key"]) {
// Ignore known keys
} else {
NSLog(@"Unknown alert key: %@", k2);
DLog(@"Unknown alert key: %@", k2);
}
}
} else {
Expand All @@ -726,7 +726,7 @@ - (NSDictionary*)parseUserInfo:(NSDictionary *)userInfo {
} else if ([k2 isEqualToString:@"sound"]) {
notification[@"sound"] = aps[k2];
} else {
NSLog(@"Unknown aps key: %@", k2);
DLog(@"Unknown aps key: %@", k2);
}
}
} else if ([k1 isEqualToString:@"gcm.message_id"]) {
Expand Down

0 comments on commit a506d1e

Please sign in to comment.