Skip to content

Commit 2ea996b

Browse files
committed
Merge pull request #22 from adeven/development
Simplify AILogger
2 parents 47920cd + 3939b0d commit 2ea996b

File tree

10 files changed

+31
-104
lines changed

10 files changed

+31
-104
lines changed

AdjustIO.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pod::Spec.new do |s|
22
s.name = "AdjustIO"
3-
s.version = "2.1.1"
3+
s.version = "2.1.2"
44
s.summary = "This is the iOS SDK of AdjustIo. You can read more about it at http://adjust.io."
55
s.homepage = "http://adjust.io"
66
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
77
s.author = { "Christian Wellenbrock" => "[email protected]" }
8-
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.1.1" }
8+
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.1.2" }
99
s.platform = :ios, '4.3'
1010
s.framework = 'AdSupport', 'SystemConfiguration'
1111
s.source_files = 'AdjustIo/*.{h,m}', 'AdjustIo/AIAdditions/*.{h,m}'

AdjustIo/AIActivityHandler.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ - (BOOL)updateActivityState {
264264
double lastInterval = now - self.activityState.lastActivity;
265265
if (lastInterval < 0) {
266266
[AILogger error:@"Time travel!"];
267-
self.activityState.lastInterval = now;
267+
self.activityState.lastActivity = now;
268268
return YES;
269269
}
270270

AdjustIo/AIActivityState.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@property (nonatomic, assign) double createdAt;
2424
@property (nonatomic, assign) double lastInterval;
2525

26-
- (void)resetSessionAttributes:(long)now;
26+
- (void)resetSessionAttributes:(double)now;
2727

2828
- (void)injectSessionAttributes:(AIPackageBuilder *)packageBilder;
2929
- (void)injectEventAttributes:(AIPackageBuilder *)packageBilder;

AdjustIo/AIActivityState.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ - (id)init {
2929
return self;
3030
}
3131

32-
- (void)resetSessionAttributes:(long)now {
32+
- (void)resetSessionAttributes:(double)now {
3333
self.subsessionCount = 1;
3434
self.sessionLength = 0;
3535
self.timeSpent = 0;

AdjustIo/AILogger.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,13 @@ typedef enum {
1818
// A simple logger with multiple log levels.
1919
@interface AILogger : NSObject
2020

21-
@property (copy) NSString *logTag;
22-
@property (assign) AILogLevel logLevel;
23-
24-
// convenience methods
25-
+ (void)setLogTag:(NSString *)logTag;
2621
+ (void)setLogLevel:(AILogLevel)logLevel;
22+
2723
+ (void)verbose:(NSString *)message, ...;
2824
+ (void)debug: (NSString *)message, ...;
2925
+ (void)info: (NSString *)message, ...;
3026
+ (void)warn: (NSString *)message, ...;
3127
+ (void)error: (NSString *)message, ...;
3228
+ (void)assert: (NSString *)message, ...;
3329

34-
+ (AILogger *)loggerWithTag:(NSString *)logTag;
35-
- (id)initWithTag:(NSString *)logTag;
36-
37-
- (void)verbose:(NSString *)message, ...;
38-
- (void)debug: (NSString *)message, ...;
39-
- (void)info: (NSString *)message, ...;
40-
- (void)warn: (NSString *)message, ...;
41-
- (void)error: (NSString *)message, ...;
42-
- (void)assert: (NSString *)message, ...;
43-
4430
@end

AdjustIo/AILogger.m

Lines changed: 19 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,122 +8,63 @@
88

99
#import "AILogger.h"
1010

11-
static AILogger *defaultLogger;
11+
static NSString * const kLogTag = @"AdjustIo";
12+
13+
static AILogLevel staticLogLevel = AILogLevelInfo;
1214

1315

1416
#pragma mark -
1517
@implementation AILogger
1618

17-
+ (void)setLogTag:(NSString *)logTag {
18-
AILogger.getDefaultLogger.logTag = logTag;
19-
}
20-
2119
+ (void)setLogLevel:(AILogLevel)logLevel {
22-
AILogger.getDefaultLogger.logLevel = logLevel;
23-
}
24-
25-
+ (AILogger *)loggerWithTag:(NSString *)logTag {
26-
return [[AILogger alloc] initWithTag:logTag];
27-
}
28-
29-
- (id)initWithTag:(NSString *)tag {
30-
self = [super init];
31-
if (self == nil) return nil;
32-
33-
self.logTag = tag;
34-
self.logLevel = AILogLevelInfo;
35-
36-
return self;
37-
}
38-
39-
- (void)verbose:(NSString *)format, ... {
40-
if (self.logLevel > AILogLevelVerbose) return;
41-
va_list parameters; va_start(parameters, format);
42-
[self logLevel:@"v" format:format parameters:parameters];
43-
}
44-
45-
- (void)debug:(NSString *)format, ... {
46-
if (self.logLevel > AILogLevelDebug) return;
47-
va_list parameters; va_start(parameters, format);
48-
[self logLevel:@"d" format:format parameters:parameters];
49-
}
50-
51-
- (void)info:(NSString *)format, ... {
52-
if (self.logLevel > AILogLevelInfo) return;
53-
va_list parameters; va_start(parameters, format);
54-
[self logLevel:@"i" format:format parameters:parameters];
55-
}
56-
57-
- (void)warn:(NSString *)format, ... {
58-
if (self.logLevel > AILogLevelWarn) return;
59-
va_list parameters; va_start(parameters, format);
60-
[self logLevel:@"w" format:format parameters:parameters];
61-
}
62-
63-
- (void)error:(NSString *)format, ... {
64-
if (self.logLevel > AILogLevelError) return;
65-
va_list parameters; va_start(parameters, format);
66-
[self logLevel:@"e" format:format parameters:parameters];
67-
}
68-
69-
- (void)assert: (NSString *)format, ... {
70-
if (self.logLevel > AILogLevelAssert) return;
71-
va_list parameters; va_start(parameters, format);
72-
[self logLevel:@"a" format:format parameters:parameters];
20+
staticLogLevel = logLevel;
7321
}
7422

7523
+ (void)verbose:(NSString *)format, ... {
76-
if (AILogger.getDefaultLogger.logLevel > AILogLevelVerbose) return;
24+
if (staticLogLevel > AILogLevelVerbose) return;
7725
va_list parameters; va_start(parameters, format);
78-
[AILogger.getDefaultLogger logLevel:@"v" format:format parameters:parameters];
26+
[self logLevel:@"v" format:format parameters:parameters];
7927
}
8028

8129
+ (void)debug:(NSString *)format, ... {
82-
if (AILogger.getDefaultLogger.logLevel > AILogLevelDebug) return;
30+
if (staticLogLevel > AILogLevelDebug) return;
8331
va_list parameters; va_start(parameters, format);
84-
[AILogger.getDefaultLogger logLevel:@"d" format:format parameters:parameters];
32+
[self logLevel:@"d" format:format parameters:parameters];
8533
}
8634

8735
+ (void)info:(NSString *)format, ... {
88-
if (AILogger.getDefaultLogger.logLevel > AILogLevelInfo) return;
36+
if (staticLogLevel > AILogLevelInfo) return;
8937
va_list parameters; va_start(parameters, format);
90-
[AILogger.getDefaultLogger logLevel:@"i" format:format parameters:parameters];
38+
[self logLevel:@"i" format:format parameters:parameters];
9139
}
9240

9341
+ (void)warn:(NSString *)format, ... {
94-
if (AILogger.getDefaultLogger.logLevel > AILogLevelWarn) return;
42+
if (staticLogLevel > AILogLevelWarn) return;
9543
va_list parameters; va_start(parameters, format);
96-
[AILogger.getDefaultLogger logLevel:@"w" format:format parameters:parameters];
44+
[self logLevel:@"w" format:format parameters:parameters];
9745
}
9846

9947
+ (void)error:(NSString *)format, ... {
100-
if (AILogger.getDefaultLogger.logLevel > AILogLevelError) return;
48+
if (staticLogLevel > AILogLevelError) return;
10149
va_list parameters; va_start(parameters, format);
102-
[AILogger.getDefaultLogger logLevel:@"e" format:format parameters:parameters];
50+
[self logLevel:@"e" format:format parameters:parameters];
10351
}
10452

10553
+ (void)assert:(NSString *)format, ... {
106-
if (AILogger.getDefaultLogger.logLevel > AILogLevelAssert) return;
54+
if (staticLogLevel > AILogLevelAssert) return;
10755
va_list parameters; va_start(parameters, format);
108-
[AILogger.getDefaultLogger logLevel:@"e" format:format parameters:parameters];
56+
[self logLevel:@"a" format:format parameters:parameters];
10957
}
11058

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

11564
NSArray *lines = [string componentsSeparatedByString:@"\n"];
11665
for (NSString *line in lines) {
117-
NSLog(@"\t[%@]%@: %@", self.logTag, logLevel, line);
118-
}
119-
}
120-
121-
#pragma mark private
122-
+ (AILogger *)getDefaultLogger {
123-
if (defaultLogger == nil) {
124-
defaultLogger = [AILogger loggerWithTag:@"AdjustIo"];
66+
NSLog(@"\t[%@]%@: %@", kLogTag, logLevel, line);
12567
}
126-
return defaultLogger;
12768
}
12869

12970
@end

AdjustIo/AIUtil.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#import "UIDevice+AIAdditions.h"
1212

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

1616

1717
#pragma mark -

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your
1313
`Podfile` and continue with [step 3](#step3):
1414

1515
```ruby
16-
pod 'AdjustIO', :git => 'git://github.com/adeven/adjust_ios_sdk.git', :tag => 'v2.1.1'
16+
pod 'AdjustIO', :git => 'git://github.com/adeven/adjust_ios_sdk.git', :tag => 'v2.1.2'
1717
```
1818

1919
### 1. Get the SDK

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.1
1+
2.1.2

doc/migration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
## Migrate your AdjustIo SDK for iOS from v1.x to v2.1.1
1+
## Migrate your AdjustIo SDK for iOS from v1.x to v2.1.2
22

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

66
![][drag]
77

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

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

0 commit comments

Comments
 (0)