Skip to content

Commit 957d26e

Browse files
Tyler FoxTyler Fox
Tyler Fox
authored and
Tyler Fox
committed
Disable NSLog for Release builds or by defining INTU_ENABLE_LOGGING = 0 in preprocessor
Merge pull request #1 from @podkovyrin.
1 parent ac47241 commit 957d26e

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Source/INTULocationManager.m

+22-7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@
2727
#import "INTULocationRequest.h"
2828

2929

30+
#ifndef INTU_ENABLE_LOGGING
31+
#ifdef DEBUG
32+
#define INTU_ENABLE_LOGGING 1
33+
#else
34+
#define INTU_ENABLE_LOGGING 0
35+
#endif /* DEBUG */
36+
#endif /* INTU_ENABLE_LOGGING */
37+
38+
#if INTU_ENABLE_LOGGING
39+
#define INTULMLog(...) NSLog(@"INTULocationManager: %@", [NSString stringWithFormat:__VA_ARGS__]);
40+
#else
41+
#define INTULMLog(...)
42+
#endif /* INTU_ENABLE_LOGGING */
43+
44+
3045
@interface INTULocationManager () <CLLocationManagerDelegate, INTULocationRequestDelegate>
3146

3247
// The instance of CLLocationManager encapsulated by this class.
@@ -145,7 +160,7 @@ - (void)cancelLocationRequest:(NSInteger)requestID
145160
}
146161
[self.locationRequests removeObject:locationRequestToCancel];
147162
[locationRequestToCancel cancelLocationRequest];
148-
NSLog(@"INTULocationManager: Location Request cancelled with ID: %ld", (long)locationRequestToCancel.requestID);
163+
INTULMLog(@"Location Request cancelled with ID: %ld", (long)locationRequestToCancel.requestID);
149164
[self stopUpdatingLocationIfPossible];
150165
}
151166

@@ -165,7 +180,7 @@ - (void)addLocationRequest:(INTULocationRequest *)locationRequest
165180

166181
[self startUpdatingLocationIfNeeded];
167182
[self.locationRequests addObject:locationRequest];
168-
NSLog(@"INTULocationManager: Location Request added with ID: %ld", (long)locationRequest.requestID);
183+
INTULMLog(@"Location Request added with ID: %ld", (long)locationRequest.requestID);
169184
}
170185

171186
/**
@@ -197,7 +212,7 @@ - (void)startUpdatingLocationIfNeeded
197212
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
198213
[self.locationManager startUpdatingLocation];
199214
if (self.isUpdatingLocation == NO) {
200-
NSLog(@"INTULocationManager: Location services started.");
215+
INTULMLog(@"Location services started.");
201216
}
202217
self.isUpdatingLocation = YES;
203218
}
@@ -212,7 +227,7 @@ - (void)stopUpdatingLocationIfPossible
212227
if ([self.locationRequests count] == 0) {
213228
[self.locationManager stopUpdatingLocation];
214229
if (self.isUpdatingLocation) {
215-
NSLog(@"INTULocationManager: Location services stopped.");
230+
INTULMLog(@"Location services stopped.");
216231
}
217232
self.isUpdatingLocation = NO;
218233
}
@@ -267,7 +282,7 @@ - (void)completeAllLocationRequests
267282
for (INTULocationRequest *locationRequest in locationRequests) {
268283
[self completeLocationRequest:locationRequest];
269284
}
270-
NSLog(@"INTULocationManager: Finished completing all location requests.");
285+
INTULMLog(@"Finished completing all location requests.");
271286
}
272287

273288
/**
@@ -291,7 +306,7 @@ - (void)completeLocationRequest:(INTULocationRequest *)locationRequest
291306
if (locationRequest.block) {
292307
locationRequest.block(currentLocation, achievedAccuracy, status);
293308
}
294-
NSLog(@"INTULocationManager: Location Request completed with ID: %ld, currentLocation: %@, achievedAccuracy: %lu, status: %lu", (long)locationRequest.requestID, currentLocation, (unsigned long) achievedAccuracy, (unsigned long)status);
309+
INTULMLog(@"Location Request completed with ID: %ld, currentLocation: %@, achievedAccuracy: %lu, status: %lu", (long)locationRequest.requestID, currentLocation, (unsigned long) achievedAccuracy, (unsigned long)status);
295310
}
296311

297312
/**
@@ -389,7 +404,7 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray
389404

390405
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
391406
{
392-
NSLog(@"INTULocationManager: Location update error: %@", [error localizedDescription]);
407+
INTULMLog(@"Location update error: %@", [error localizedDescription]);
393408
self.updateFailed = YES;
394409

395410
[self completeAllLocationRequests];

0 commit comments

Comments
 (0)