Skip to content

Commit 61b3839

Browse files
Merge pull request #22 from Iterable/feature/itbl-6124-logging
[ITBL-6124] - logging
2 parents 80410a9 + 357f62e commit 61b3839

File tree

6 files changed

+1668
-38
lines changed

6 files changed

+1668
-38
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
//
3+
// Created by Tapash Majumder on 9/4/18.
4+
// Copyright © 2018 Iterable. All rights reserved.
5+
//
6+
7+
import XCTest
8+
@testable import IterableSDK
9+
10+
class LoggingTests: XCTestCase {
11+
12+
override func setUp() {
13+
super.setUp()
14+
// Put setup code here. This method is called before the invocation of each test method in the class.
15+
}
16+
17+
override func tearDown() {
18+
// Put teardown code here. This method is called after the invocation of each test method in the class.
19+
super.tearDown()
20+
}
21+
22+
func testLogging() {
23+
class LogDelegate : IterableLogDelegate {
24+
var level: LogLevel? = nil
25+
var message: String? = nil
26+
27+
func log(level: LogLevel, message: String) {
28+
self.level = level
29+
self.message = message
30+
}
31+
}
32+
33+
let logDelegate = LogDelegate()
34+
let config = IterableConfig()
35+
config.logLevel = .error
36+
config.logDelegate = logDelegate
37+
IterableAPI.initialize(apiKey: "apiKey", config: config)
38+
39+
ITBDebug("debug message")
40+
XCTAssert(logDelegate.level == .debug)
41+
XCTAssert(logDelegate.message!.contains("debug message"))
42+
43+
ITBInfo("info message")
44+
XCTAssert(logDelegate.level == .info)
45+
XCTAssert(logDelegate.message!.contains("info message"))
46+
47+
ITBError("error message")
48+
XCTAssert(logDelegate.level == .error)
49+
XCTAssert(logDelegate.message!.contains("error message"))
50+
}
51+
52+
}

swift-sdk.xcodeproj/project.pbxproj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
AC347B5C20E5A7E1003449CF /* IterableAPNSUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC347B5B20E5A7E1003449CF /* IterableAPNSUtil.swift */; };
2525
AC347B5D20E5C7C6003449CF /* IterableConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = AC72A0B120CF4C32004D7997 /* IterableConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
2626
AC347B6720E699FA003449CF /* IterableAppExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = AC347B6620E699D8003449CF /* IterableAppExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
27+
AC3C10F9213F46A900A9B839 /* IterableLogging.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC3C10F8213F46A900A9B839 /* IterableLogging.swift */; };
2728
AC426CC4211B5497002EDBE8 /* ServerResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC426CC3211B5497002EDBE8 /* ServerResponse.swift */; };
2829
AC6FDD8820F4372E005D811E /* IterableAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC6FDD8720F4372E005D811E /* IterableAPI.swift */; };
2930
AC6FDD8C20F56309005D811E /* IterableInAppNotificationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC6FDD8B20F56309005D811E /* IterableInAppNotificationTests.swift */; };
@@ -65,6 +66,7 @@
6566
ACE34AB321376B1000691224 /* UserDefaultsLocalStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACE34AB221376B1000691224 /* UserDefaultsLocalStorage.swift */; };
6667
ACE34AB5213776CB00691224 /* LocalStorageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACE34AB4213776CB00691224 /* LocalStorageTests.swift */; };
6768
ACE34AB72139D70B00691224 /* LocalStorageProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACE34AB62139D70B00691224 /* LocalStorageProtocol.swift */; };
69+
ACED4C01213F50B30055A497 /* LoggingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACED4C00213F50B30055A497 /* LoggingTests.swift */; };
6870
ACF560D620E443BF000AAC23 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF560D520E443BF000AAC23 /* AppDelegate.swift */; };
6971
ACF560D820E443BF000AAC23 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF560D720E443BF000AAC23 /* ViewController.swift */; };
7072
ACF560DB20E443BF000AAC23 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ACF560D920E443BF000AAC23 /* Main.storyboard */; };
@@ -140,6 +142,7 @@
140142
AC2C668620D3435700D46CC9 /* IterableActionRunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IterableActionRunnerTests.swift; sourceTree = "<group>"; };
141143
AC347B5B20E5A7E1003449CF /* IterableAPNSUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IterableAPNSUtil.swift; sourceTree = "<group>"; };
142144
AC347B6620E699D8003449CF /* IterableAppExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IterableAppExtensions.h; sourceTree = "<group>"; };
145+
AC3C10F8213F46A900A9B839 /* IterableLogging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IterableLogging.swift; sourceTree = "<group>"; };
143146
AC426CC3211B5497002EDBE8 /* ServerResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerResponse.swift; sourceTree = "<group>"; };
144147
AC431DF320D18E9000BFAFD1 /* swift-sdk-objc-tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "swift-sdk-objc-tests-Bridging-Header.h"; sourceTree = "<group>"; };
145148
AC6FDD8720F4372E005D811E /* IterableAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IterableAPI.swift; sourceTree = "<group>"; };
@@ -187,6 +190,7 @@
187190
ACE34AB221376B1000691224 /* UserDefaultsLocalStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsLocalStorage.swift; sourceTree = "<group>"; };
188191
ACE34AB4213776CB00691224 /* LocalStorageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalStorageTests.swift; sourceTree = "<group>"; };
189192
ACE34AB62139D70B00691224 /* LocalStorageProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalStorageProtocol.swift; sourceTree = "<group>"; };
193+
ACED4C00213F50B30055A497 /* LoggingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggingTests.swift; sourceTree = "<group>"; };
190194
ACF560D320E443BF000AAC23 /* host-app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "host-app.app"; sourceTree = BUILT_PRODUCTS_DIR; };
191195
ACF560D520E443BF000AAC23 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
192196
ACF560D720E443BF000AAC23 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@@ -350,6 +354,14 @@
350354
name = "Helper Files";
351355
sourceTree = "<group>";
352356
};
357+
AC3C10F7213F43AC00A9B839 /* Logging */ = {
358+
isa = PBXGroup;
359+
children = (
360+
AC3C10F8213F46A900A9B839 /* IterableLogging.swift */,
361+
);
362+
name = Logging;
363+
sourceTree = "<group>";
364+
};
353365
AC426CC5211B5527002EDBE8 /* Fp */ = {
354366
isa = PBXGroup;
355367
children = (
@@ -383,6 +395,7 @@
383395
AC72A0BB20CF4C8C004D7997 /* Internal */ = {
384396
isa = PBXGroup;
385397
children = (
398+
AC3C10F7213F43AC00A9B839 /* Logging */,
386399
ACE34AB121376ACB00691224 /* Local Storage */,
387400
AC426CC5211B5527002EDBE8 /* Fp */,
388401
AC2263FA20CF4B84009800EB /* InApp Notifications */,
@@ -414,6 +427,7 @@
414427
AC89661D2124FBCE0051A6CD /* IterableAutoRegistrationTests.swift */,
415428
ACE34AB4213776CB00691224 /* LocalStorageTests.swift */,
416429
007960ED213F8B2300C53A6A /* DeferredDeeplinkTests.swift */,
430+
ACED4C00213F50B30055A497 /* LoggingTests.swift */,
417431
);
418432
path = "swift-sdk-swift-tests";
419433
sourceTree = "<group>";
@@ -814,6 +828,7 @@
814828
AC72A0CF20CF4CE2004D7997 /* IterableNotificationMetadata.swift in Sources */,
815829
ACD6116C2107D004003E7F6B /* NetworkHelper.swift in Sources */,
816830
AC72A0D220CF4D12004D7997 /* IterableUtil.swift in Sources */,
831+
AC3C10F9213F46A900A9B839 /* IterableLogging.swift in Sources */,
817832
ACE34AB72139D70B00691224 /* LocalStorageProtocol.swift in Sources */,
818833
AC6FDD8820F4372E005D811E /* IterableAPI.swift in Sources */,
819834
ACF560E820E55A6B000AAC23 /* IterableActionContext.swift in Sources */,
@@ -842,6 +857,7 @@
842857
AC89661E2124FBCE0051A6CD /* IterableAutoRegistrationTests.swift in Sources */,
843858
00B6FACC210E8484007535CF /* APNSUtilTests.swift in Sources */,
844859
007960EE213F8B2300C53A6A /* DeferredDeeplinkTests.swift in Sources */,
860+
ACED4C01213F50B30055A497 /* LoggingTests.swift in Sources */,
845861
AC776DA4211A17C700C27C27 /* IterableRequestUtilTests.swift in Sources */,
846862
ACE34AB5213776CB00691224 /* LocalStorageTests.swift in Sources */,
847863
AC6FDD8C20F56309005D811E /* IterableInAppNotificationTests.swift in Sources */,
@@ -1088,7 +1104,6 @@
10881104
);
10891105
MACH_O_TYPE = mh_dylib;
10901106
OTHER_SWIFT_FLAGS = "";
1091-
"OTHER_SWIFT_FLAGS[arch=*]" = "-D LOG";
10921107
PRODUCT_BUNDLE_IDENTIFIER = "iterable.swift-sdk";
10931108
PRODUCT_NAME = IterableSDK;
10941109
PROVISIONING_PROFILE_SPECIFIER = "";

0 commit comments

Comments
 (0)