From 386892ae4679e9e6851d00fd0a4edc62e83c9efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ko=CC=88nig?= Date: Mon, 9 Jan 2017 22:34:57 +0100 Subject: [PATCH] Temporarily replaced XCGLogger with a simple logging implementation --- Cartfile | 1 - Cartfile.resolved | 1 - Figo.xcodeproj/project.pbxproj | 34 +++++----------------- README.md | 10 ------- Source/Core/Logging.swift | 42 ++++++++++++++++++++++++--- Source/{ => Dependencies}/Unbox.swift | 0 Source/FigoClient.swift | 6 +--- Tests/BaseTestCaseWithLogin.swift | 6 +--- 8 files changed, 47 insertions(+), 53 deletions(-) delete mode 100644 Cartfile delete mode 100644 Cartfile.resolved rename Source/{ => Dependencies}/Unbox.swift (100%) diff --git a/Cartfile b/Cartfile deleted file mode 100644 index a8ef1a7..0000000 --- a/Cartfile +++ /dev/null @@ -1 +0,0 @@ -github "DaveWoodCom/XCGLogger" diff --git a/Cartfile.resolved b/Cartfile.resolved deleted file mode 100644 index d3f73eb..0000000 --- a/Cartfile.resolved +++ /dev/null @@ -1 +0,0 @@ -github "DaveWoodCom/XCGLogger" "Version_4.0.0" diff --git a/Figo.xcodeproj/project.pbxproj b/Figo.xcodeproj/project.pbxproj index 27efc85..d12e910 100644 --- a/Figo.xcodeproj/project.pbxproj +++ b/Figo.xcodeproj/project.pbxproj @@ -8,13 +8,12 @@ /* Begin PBXBuildFile section */ 83017B781C0A2FE80062FC08 /* TaskState.json in Resources */ = {isa = PBXBuildFile; fileRef = 83017B771C0A2FE80062FC08 /* TaskState.json */; }; - 830493581E202957005B5B30 /* Unbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830493571E202957005B5B30 /* Unbox.swift */; }; 830E63D91C05A4050048F7BF /* TANScheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830E63D81C05A4050048F7BF /* TANScheme.swift */; }; 830E63DC1C05A4960048F7BF /* TanScheme.json in Resources */ = {isa = PBXBuildFile; fileRef = 830E63DB1C05A4960048F7BF /* TanScheme.json */; }; 830E63DE1C05A7070048F7BF /* SyncStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830E63DD1C05A7070048F7BF /* SyncStatus.swift */; }; 830E63E11C05A7AE0048F7BF /* SyncStatus.json in Resources */ = {isa = PBXBuildFile; fileRef = 830E63E01C05A7AE0048F7BF /* SyncStatus.json */; }; 830E63E31C05AB890048F7BF /* PaymentParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830E63E21C05AB890048F7BF /* PaymentParameters.swift */; }; - 832CABA91E242BAF00D48895 /* XCGLogger.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 832CABA81E242BAF00D48895 /* XCGLogger.framework */; }; + 832CABAE1E242F8700D48895 /* Unbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 832CABAD1E242F8700D48895 /* Unbox.swift */; }; 833285EF1C04D45900A9FE73 /* Balance.json in Resources */ = {isa = PBXBuildFile; fileRef = 833285EE1C04D45900A9FE73 /* Balance.json */; }; 8346AABF1C0A03A700F9F0DE /* TaskEndpoints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8346AABE1C0A03A700F9F0DE /* TaskEndpoints.swift */; }; 83648D571C0A42B700286FFB /* LoginSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83648D561C0A42B700286FFB /* LoginSettings.swift */; }; @@ -105,13 +104,12 @@ /* Begin PBXFileReference section */ 83017B771C0A2FE80062FC08 /* TaskState.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = TaskState.json; path = Resources/TaskState.json; sourceTree = ""; }; - 830493571E202957005B5B30 /* Unbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unbox.swift; sourceTree = ""; }; 830E63D81C05A4050048F7BF /* TANScheme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TANScheme.swift; path = Types/TANScheme.swift; sourceTree = ""; }; 830E63DB1C05A4960048F7BF /* TanScheme.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = TanScheme.json; path = Resources/TanScheme.json; sourceTree = ""; }; 830E63DD1C05A7070048F7BF /* SyncStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SyncStatus.swift; path = Types/SyncStatus.swift; sourceTree = ""; }; 830E63E01C05A7AE0048F7BF /* SyncStatus.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = SyncStatus.json; path = Resources/SyncStatus.json; sourceTree = ""; }; 830E63E21C05AB890048F7BF /* PaymentParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PaymentParameters.swift; path = Types/PaymentParameters.swift; sourceTree = ""; }; - 832CABA81E242BAF00D48895 /* XCGLogger.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCGLogger.framework; path = Carthage/Build/iOS/XCGLogger.framework; sourceTree = ""; }; + 832CABAD1E242F8700D48895 /* Unbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unbox.swift; sourceTree = ""; }; 833285EE1C04D45900A9FE73 /* Balance.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = Balance.json; path = Resources/Balance.json; sourceTree = ""; }; 833285F01C04D48E00A9FE73 /* Resources.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Resources.swift; sourceTree = ""; }; 8346AABE1C0A03A700F9F0DE /* TaskEndpoints.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TaskEndpoints.swift; sourceTree = ""; }; @@ -197,19 +195,18 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 832CABA91E242BAF00D48895 /* XCGLogger.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 832CABA71E242BAE00D48895 /* Frameworks */ = { + 832CABAA1E242F3F00D48895 /* Dependencies */ = { isa = PBXGroup; children = ( - 832CABA81E242BAF00D48895 /* XCGLogger.framework */, + 832CABAD1E242F8700D48895 /* Unbox.swift */, ); - name = Frameworks; + path = Dependencies; sourceTree = ""; }; 837B520F1C10C97E00D3CB25 /* Core */ = { @@ -240,7 +237,6 @@ 83D3A67F1BFF2953003EDE45 /* Source */ = { isa = PBXGroup; children = ( - 830493571E202957005B5B30 /* Unbox.swift */, 83F0E46B1C08A91400FB3709 /* FigoClient.swift */, 837B520C1C10C95500D3CB25 /* Alias.swift */, 838FDA041C0DF90100525E1D /* FigoError.swift */, @@ -250,6 +246,7 @@ 83F0E4721C08D9EA00FB3709 /* Endpoints */, 838FD9F31C0DF8D900525E1D /* Parameters */, 83D3A6FA1BFF684C003EDE45 /* Types */, + 832CABAA1E242F3F00D48895 /* Dependencies */, 83D3A6801BFF2953003EDE45 /* Supporting Files */, ); path = Source; @@ -356,7 +353,6 @@ 83D3A67F1BFF2953003EDE45 /* Source */, 83D3A7081BFFB6A7003EDE45 /* Tests */, 83F3AF231BFF28D900767D77 /* Products */, - 832CABA71E242BAE00D48895 /* Frameworks */, ); sourceTree = ""; }; @@ -512,6 +508,7 @@ files = ( 8346AABF1C0A03A700F9F0DE /* TaskEndpoints.swift in Sources */, 83648D5A1C0C32BE00286FFB /* ServiceEndpoints.swift in Sources */, + 832CABAE1E242F8700D48895 /* Unbox.swift in Sources */, 838FD9EE1C0DEEFD00525E1D /* PaymentType.swift in Sources */, 830E63E31C05AB890048F7BF /* PaymentParameters.swift in Sources */, 838FD9E31C0DACBE00525E1D /* Transaction.swift in Sources */, @@ -522,7 +519,6 @@ 83F0E4781C08DA2800FB3709 /* Address.swift in Sources */, 838FDA221C0EE54000525E1D /* StandingOrder.swift in Sources */, 83648D661C0C75E600286FFB /* SupportedService.swift in Sources */, - 830493581E202957005B5B30 /* Unbox.swift in Sources */, 838FD9F91C0DF8D900525E1D /* CreateAccountParameters.swift in Sources */, 83648D631C0C705700286FFB /* SupportedBank.swift in Sources */, 838FDA361C0EFC0300525E1D /* Payment.swift in Sources */, @@ -574,10 +570,6 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "de.chriskoenig.Figo-iOS-Tests"; @@ -591,10 +583,6 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "de.chriskoenig.Figo-iOS-Tests"; @@ -719,10 +707,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; @@ -738,10 +722,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; diff --git a/README.md b/README.md index d574059..4fbc997 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,6 @@ Applications that would like to access the figo Connect have to register with us Website: [http://figo.io](http://figo.io) -## Development - -If you want to run the included tests to see how the SDK works or submit a pull request, you need to bootstrap the project by running - -`carthage bootstrap` - -You can find a demo account in the API reference, which you can use without registering an application. - ## Installation ### Manually @@ -47,7 +39,6 @@ You can find a demo account in the API reference, which you can use without regi * Open the new folder and drag the Figo.xcodeproj into the Project Navigator of your application's Xcode project. * Select the Figo.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target. * Add the Figo.framework to your target(s) in the "Embedded Binaries" sections -* Add [DaveWoodCom/XCGLogger](https://github.com/DaveWoodCom/XCGLogger) to your project ### Carthage @@ -228,7 +219,6 @@ Bank accounts can have standing orders associated with it if supported by the re The Figo Framework uses the following 3rd-party utilities: -- [DaveWoodCom/XCGLogger](https://github.com/DaveWoodCom/XCGLogger) for logging - [JohnSundell/Unbox](https://github.com/JohnSundell/Unbox) for unboxing of JSON responses diff --git a/Source/Core/Logging.swift b/Source/Core/Logging.swift index 20150c8..8c2c4f8 100644 --- a/Source/Core/Logging.swift +++ b/Source/Core/Logging.swift @@ -7,11 +7,44 @@ // import Foundation -import XCGLogger // Internal logger instance -internal var log = XCGLogger.default +internal var log: Logger = VoidLogger() + + +public protocol Logger { + var debug: (String) -> Void { get } + var verbose: (String) -> Void { get } + var error: (String) -> Void { get } +} + +public struct VoidLogger: Logger { + public var debug: (String) -> Void = { message in + + } + public var verbose: (String) -> Void = { message in + + } + public var error: (String) -> Void = { message in + + } +} + +public struct ConsoleLogger: Logger { + public init() { + + } + public var debug: (String) -> Void = { message in + print(message) + } + public var verbose: (String) -> Void = { message in + print(message) + } + public var error: (String) -> Void = { message in + print(message) + } +} func debugPrintRequest(_ request: URLRequest) { @@ -22,8 +55,9 @@ func debugPrintRequest(_ request: URLRequest) { } } if let data = request.httpBody { - let string = String(data: data, encoding: String.Encoding.utf8) - log.verbose(string) + if let string = String(data: data, encoding: String.Encoding.utf8) { + log.verbose(string) + } } } diff --git a/Source/Unbox.swift b/Source/Dependencies/Unbox.swift similarity index 100% rename from Source/Unbox.swift rename to Source/Dependencies/Unbox.swift diff --git a/Source/FigoClient.swift b/Source/FigoClient.swift index ce59773..950d33e 100644 --- a/Source/FigoClient.swift +++ b/Source/FigoClient.swift @@ -7,7 +7,6 @@ // import Foundation -import XCGLogger // Server's SHA1 fingerprints @@ -60,7 +59,7 @@ open class FigoClient { - Note: SSL pinning is implemented in the NSURLSessionDelegate. So if you provide your own NSURLSession, make sure to use FigoClient.dispositionForChallenge(:) in your own NSURLSessionDelegate to enable SSL pinning. */ - public init(session: URLSession? = nil, logger: XCGLogger? = nil) { + public init(session: URLSession? = nil, logger: Logger? = nil) { if let session = session { self.session = session } else { @@ -68,9 +67,6 @@ open class FigoClient { } if let logger = logger { log = logger - } else { - log = XCGLogger.default - log.setup(level: .error, showFunctionName: false, showThreadName: false, showLevel: false, showFileNames: false, showLineNumbers: false, showDate: false, writeToFile: nil, fileLevel: .none) } } diff --git a/Tests/BaseTestCaseWithLogin.swift b/Tests/BaseTestCaseWithLogin.swift index f31cbb6..df24adc 100644 --- a/Tests/BaseTestCaseWithLogin.swift +++ b/Tests/BaseTestCaseWithLogin.swift @@ -9,11 +9,9 @@ import Foundation import XCTest import Figo -import XCGLogger -let logger = XCGLogger.default -let figo = FigoClient(logger: logger) +let figo = FigoClient(logger: ConsoleLogger()) class BaseTestCaseWithLogin: XCTestCase { @@ -32,8 +30,6 @@ class BaseTestCaseWithLogin: XCTestCase { override class func setUp() { super.setUp() - - logger.setup(level: .verbose, showFunctionName: false, showThreadName: false, showLevel: false, showFileNames: false, showLineNumbers: false, showDate: false, writeToFile: nil, fileLevel: .none) } func login(_ completionHandler: @escaping () -> Void) {