Skip to content

Commit

Permalink
Merge pull request #22 from adeven/development
Browse files Browse the repository at this point in the history
Simplify AILogger
  • Loading branch information
wellle committed Jan 7, 2014
2 parents 47920cd + 3939b0d commit 2ea996b
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 104 deletions.
4 changes: 2 additions & 2 deletions AdjustIO.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "AdjustIO"
s.version = "2.1.1"
s.version = "2.1.2"
s.summary = "This is the iOS SDK of AdjustIo. You can read more about it at http://adjust.io."
s.homepage = "http://adjust.io"
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
s.author = { "Christian Wellenbrock" => "[email protected]" }
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.1.1" }
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.1.2" }
s.platform = :ios, '4.3'
s.framework = 'AdSupport', 'SystemConfiguration'
s.source_files = 'AdjustIo/*.{h,m}', 'AdjustIo/AIAdditions/*.{h,m}'
Expand Down
2 changes: 1 addition & 1 deletion AdjustIo/AIActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ - (BOOL)updateActivityState {
double lastInterval = now - self.activityState.lastActivity;
if (lastInterval < 0) {
[AILogger error:@"Time travel!"];
self.activityState.lastInterval = now;
self.activityState.lastActivity = now;
return YES;
}

Expand Down
2 changes: 1 addition & 1 deletion AdjustIo/AIActivityState.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@property (nonatomic, assign) double createdAt;
@property (nonatomic, assign) double lastInterval;

- (void)resetSessionAttributes:(long)now;
- (void)resetSessionAttributes:(double)now;

- (void)injectSessionAttributes:(AIPackageBuilder *)packageBilder;
- (void)injectEventAttributes:(AIPackageBuilder *)packageBilder;
Expand Down
2 changes: 1 addition & 1 deletion AdjustIo/AIActivityState.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ - (id)init {
return self;
}

- (void)resetSessionAttributes:(long)now {
- (void)resetSessionAttributes:(double)now {
self.subsessionCount = 1;
self.sessionLength = 0;
self.timeSpent = 0;
Expand Down
16 changes: 1 addition & 15 deletions AdjustIo/AILogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,13 @@ typedef enum {
// A simple logger with multiple log levels.
@interface AILogger : NSObject

@property (copy) NSString *logTag;
@property (assign) AILogLevel logLevel;

// convenience methods
+ (void)setLogTag:(NSString *)logTag;
+ (void)setLogLevel:(AILogLevel)logLevel;

+ (void)verbose:(NSString *)message, ...;
+ (void)debug: (NSString *)message, ...;
+ (void)info: (NSString *)message, ...;
+ (void)warn: (NSString *)message, ...;
+ (void)error: (NSString *)message, ...;
+ (void)assert: (NSString *)message, ...;

+ (AILogger *)loggerWithTag:(NSString *)logTag;
- (id)initWithTag:(NSString *)logTag;

- (void)verbose:(NSString *)message, ...;
- (void)debug: (NSString *)message, ...;
- (void)info: (NSString *)message, ...;
- (void)warn: (NSString *)message, ...;
- (void)error: (NSString *)message, ...;
- (void)assert: (NSString *)message, ...;

@end
97 changes: 19 additions & 78 deletions AdjustIo/AILogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,122 +8,63 @@

#import "AILogger.h"

static AILogger *defaultLogger;
static NSString * const kLogTag = @"AdjustIo";

static AILogLevel staticLogLevel = AILogLevelInfo;


#pragma mark -
@implementation AILogger

+ (void)setLogTag:(NSString *)logTag {
AILogger.getDefaultLogger.logTag = logTag;
}

+ (void)setLogLevel:(AILogLevel)logLevel {
AILogger.getDefaultLogger.logLevel = logLevel;
}

+ (AILogger *)loggerWithTag:(NSString *)logTag {
return [[AILogger alloc] initWithTag:logTag];
}

- (id)initWithTag:(NSString *)tag {
self = [super init];
if (self == nil) return nil;

self.logTag = tag;
self.logLevel = AILogLevelInfo;

return self;
}

- (void)verbose:(NSString *)format, ... {
if (self.logLevel > AILogLevelVerbose) return;
va_list parameters; va_start(parameters, format);
[self logLevel:@"v" format:format parameters:parameters];
}

- (void)debug:(NSString *)format, ... {
if (self.logLevel > AILogLevelDebug) return;
va_list parameters; va_start(parameters, format);
[self logLevel:@"d" format:format parameters:parameters];
}

- (void)info:(NSString *)format, ... {
if (self.logLevel > AILogLevelInfo) return;
va_list parameters; va_start(parameters, format);
[self logLevel:@"i" format:format parameters:parameters];
}

- (void)warn:(NSString *)format, ... {
if (self.logLevel > AILogLevelWarn) return;
va_list parameters; va_start(parameters, format);
[self logLevel:@"w" format:format parameters:parameters];
}

- (void)error:(NSString *)format, ... {
if (self.logLevel > AILogLevelError) return;
va_list parameters; va_start(parameters, format);
[self logLevel:@"e" format:format parameters:parameters];
}

- (void)assert: (NSString *)format, ... {
if (self.logLevel > AILogLevelAssert) return;
va_list parameters; va_start(parameters, format);
[self logLevel:@"a" format:format parameters:parameters];
staticLogLevel = logLevel;
}

+ (void)verbose:(NSString *)format, ... {
if (AILogger.getDefaultLogger.logLevel > AILogLevelVerbose) return;
if (staticLogLevel > AILogLevelVerbose) return;
va_list parameters; va_start(parameters, format);
[AILogger.getDefaultLogger logLevel:@"v" format:format parameters:parameters];
[self logLevel:@"v" format:format parameters:parameters];
}

+ (void)debug:(NSString *)format, ... {
if (AILogger.getDefaultLogger.logLevel > AILogLevelDebug) return;
if (staticLogLevel > AILogLevelDebug) return;
va_list parameters; va_start(parameters, format);
[AILogger.getDefaultLogger logLevel:@"d" format:format parameters:parameters];
[self logLevel:@"d" format:format parameters:parameters];
}

+ (void)info:(NSString *)format, ... {
if (AILogger.getDefaultLogger.logLevel > AILogLevelInfo) return;
if (staticLogLevel > AILogLevelInfo) return;
va_list parameters; va_start(parameters, format);
[AILogger.getDefaultLogger logLevel:@"i" format:format parameters:parameters];
[self logLevel:@"i" format:format parameters:parameters];
}

+ (void)warn:(NSString *)format, ... {
if (AILogger.getDefaultLogger.logLevel > AILogLevelWarn) return;
if (staticLogLevel > AILogLevelWarn) return;
va_list parameters; va_start(parameters, format);
[AILogger.getDefaultLogger logLevel:@"w" format:format parameters:parameters];
[self logLevel:@"w" format:format parameters:parameters];
}

+ (void)error:(NSString *)format, ... {
if (AILogger.getDefaultLogger.logLevel > AILogLevelError) return;
if (staticLogLevel > AILogLevelError) return;
va_list parameters; va_start(parameters, format);
[AILogger.getDefaultLogger logLevel:@"e" format:format parameters:parameters];
[self logLevel:@"e" format:format parameters:parameters];
}

+ (void)assert:(NSString *)format, ... {
if (AILogger.getDefaultLogger.logLevel > AILogLevelAssert) return;
if (staticLogLevel > AILogLevelAssert) return;
va_list parameters; va_start(parameters, format);
[AILogger.getDefaultLogger logLevel:@"e" format:format parameters:parameters];
[self logLevel:@"a" format:format parameters:parameters];
}

- (void)logLevel:(NSString *)logLevel format:(NSString *)format parameters:(va_list) parameters {
// private implementation
+ (void)logLevel:(NSString *)logLevel format:(NSString *)format parameters:(va_list)parameters {
NSString *string = [[NSString alloc] initWithFormat:format arguments:parameters];
va_end(parameters);

NSArray *lines = [string componentsSeparatedByString:@"\n"];
for (NSString *line in lines) {
NSLog(@"\t[%@]%@: %@", self.logTag, logLevel, line);
}
}

#pragma mark private
+ (AILogger *)getDefaultLogger {
if (defaultLogger == nil) {
defaultLogger = [AILogger loggerWithTag:@"AdjustIo"];
NSLog(@"\t[%@]%@: %@", kLogTag, logLevel, line);
}
return defaultLogger;
}

@end
2 changes: 1 addition & 1 deletion AdjustIo/AIUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import "UIDevice+AIAdditions.h"

static NSString * const kBaseUrl = @"https://app.adjust.io";
static NSString * const kClientSdk = @"ios2.1.1";
static NSString * const kClientSdk = @"ios2.1.2";


#pragma mark -
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your
`Podfile` and continue with [step 3](#step3):

```ruby
pod 'AdjustIO', :git => 'git://github.com/adeven/adjust_ios_sdk.git', :tag => 'v2.1.1'
pod 'AdjustIO', :git => 'git://github.com/adeven/adjust_ios_sdk.git', :tag => 'v2.1.2'
```

### 1. Get the SDK
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.1.2
6 changes: 3 additions & 3 deletions doc/migration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Migrate your AdjustIo SDK for iOS from v1.x to v2.1.1
## Migrate your AdjustIo SDK for iOS from v1.x to v2.1.2

1. Delete the old `AdjustIo` source folder from your Xcode project. Download
version v2.1.1 and drag the new folder into your Xcode project.
version v2.1.2 and drag the new folder into your Xcode project.

![][drag]

Expand Down Expand Up @@ -55,7 +55,7 @@
2. The `appDidLaunch` method now expects your App Token instead of your App ID.
You can find your App Token in your [dashboard].

2. The AdjustIo SDK for iOS 2.1.1 uses [ARC][arc]. If you haven't done already,
2. The AdjustIo SDK for iOS 2.1.2 uses [ARC][arc]. If you haven't done already,
we recommend [transitioning your project to use ARC][transition] as well. If
you don't want to use ARC, you have to enable ARC for all files of the
AdjustIo SDK. Please consult the [README] for details.
Expand Down

0 comments on commit 2ea996b

Please sign in to comment.