Skip to content

Commit

Permalink
Disable NSLog for Release builds or by defining INTU_ENABLE_LOGGING =…
Browse files Browse the repository at this point in the history
… 0 in preprocessor

Merge pull request #1 from @podkovyrin.
  • Loading branch information
Tyler Fox authored and Tyler Fox committed Mar 31, 2014
1 parent ac47241 commit 957d26e
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Source/INTULocationManager.m
Expand Up @@ -27,6 +27,21 @@
#import "INTULocationRequest.h"


#ifndef INTU_ENABLE_LOGGING
#ifdef DEBUG
#define INTU_ENABLE_LOGGING 1
#else
#define INTU_ENABLE_LOGGING 0
#endif /* DEBUG */
#endif /* INTU_ENABLE_LOGGING */

#if INTU_ENABLE_LOGGING
#define INTULMLog(...) NSLog(@"INTULocationManager: %@", [NSString stringWithFormat:__VA_ARGS__]);
#else
#define INTULMLog(...)
#endif /* INTU_ENABLE_LOGGING */


@interface INTULocationManager () <CLLocationManagerDelegate, INTULocationRequestDelegate>

// The instance of CLLocationManager encapsulated by this class.
Expand Down Expand Up @@ -145,7 +160,7 @@ - (void)cancelLocationRequest:(NSInteger)requestID
}
[self.locationRequests removeObject:locationRequestToCancel];
[locationRequestToCancel cancelLocationRequest];
NSLog(@"INTULocationManager: Location Request cancelled with ID: %ld", (long)locationRequestToCancel.requestID);
INTULMLog(@"Location Request cancelled with ID: %ld", (long)locationRequestToCancel.requestID);
[self stopUpdatingLocationIfPossible];
}

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

[self startUpdatingLocationIfNeeded];
[self.locationRequests addObject:locationRequest];
NSLog(@"INTULocationManager: Location Request added with ID: %ld", (long)locationRequest.requestID);
INTULMLog(@"Location Request added with ID: %ld", (long)locationRequest.requestID);
}

/**
Expand Down Expand Up @@ -197,7 +212,7 @@ - (void)startUpdatingLocationIfNeeded
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[self.locationManager startUpdatingLocation];
if (self.isUpdatingLocation == NO) {
NSLog(@"INTULocationManager: Location services started.");
INTULMLog(@"Location services started.");
}
self.isUpdatingLocation = YES;
}
Expand All @@ -212,7 +227,7 @@ - (void)stopUpdatingLocationIfPossible
if ([self.locationRequests count] == 0) {
[self.locationManager stopUpdatingLocation];
if (self.isUpdatingLocation) {
NSLog(@"INTULocationManager: Location services stopped.");
INTULMLog(@"Location services stopped.");
}
self.isUpdatingLocation = NO;
}
Expand Down Expand Up @@ -267,7 +282,7 @@ - (void)completeAllLocationRequests
for (INTULocationRequest *locationRequest in locationRequests) {
[self completeLocationRequest:locationRequest];
}
NSLog(@"INTULocationManager: Finished completing all location requests.");
INTULMLog(@"Finished completing all location requests.");
}

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

/**
Expand Down Expand Up @@ -389,7 +404,7 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray

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

[self completeAllLocationRequests];
Expand Down

0 comments on commit 957d26e

Please sign in to comment.