From 59753424adc8f5bf00e278513cbdbd9c423588a7 Mon Sep 17 00:00:00 2001 From: ks Date: Sun, 2 Feb 2020 20:36:39 +0200 Subject: [PATCH] Debug print updated --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + .../xcschemes/xcschememanagement.plist | 23 ++++++++++++++++++ Sources/.DS_Store | Bin 6148 -> 6148 bytes Sources/SKHTTPClient/.DS_Store | Bin 6148 -> 6148 bytes Sources/SKHTTPClient/SKHTTPClient.swift | 19 ++++++++++++--- 6 files changed, 40 insertions(+), 3 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index d30c0276e24d32cf2fb98bc3f8dbe8bac7220350..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO>Wab6#gbnTRW&C3#4}G4HAp0YM@cY0?AF&MHfgFu3!PEwQJK_xSlF@YL$@6 zn;rsgz)?5>2jKwl-po))0;ns5V4n2md-Hx~;&0*^4*<~{#vPyyz#(O9xYYbaIL*2~~TRzVq-!=e`so^x+6EKee1?@O6o+hO!HO{#J$8jC^puI90ZFIY<-bUxac-0#{?A|APb8|d)o#nfoN4tlo z7jH&y$CvMzCwf2V1yOR_;5T?r#uO>%!646MeoPUrn#Vpr_j&lLS}IjC#JGGH07 z4BUhPvn4sVZjx+sECZH-|B3 SchemeUserState + CacheManager.xcscheme_^#shared#^_ + + orderHint + 2 + + SKHTTPClient-Package.xcscheme_^#shared#^_ + + orderHint + 0 + SKHTTPClient.xcscheme_^#shared#^_ orderHint 0 + SuppressBuildableAutocreation + + SKHTTPClient + + primary + + + SKHTTPClientTests + + primary + + + diff --git a/Sources/.DS_Store b/Sources/.DS_Store index bbaba769e8b305d82a002da370e251c9f444308a..696548d875feacec530b88a45bad667aeaf8f9e7 100644 GIT binary patch delta 76 zcmZoMXffE3&BS32mSlCcp@oT#g0Z1Nt&T#qp`nSXj)JL)L2WH3hq$Vtt!F}R gWmR=eZQZQNqRjG)vnTT~$!rc}-paC>o#QV*09@A=cK`qY delta 75 zcmZoMXffE3&BS32rbKnMiK(fMf{CGVt&T#qrKu5+ZEjv$%gG_GYG~`3kXu<* eT~k{(bFvt-Jmaj%JWMj1gP6CnY-Z#5#}5Ea#uirq diff --git a/Sources/SKHTTPClient/.DS_Store b/Sources/SKHTTPClient/.DS_Store index c0c86f6d7a7f189a7b671f715c349a4951e2eabc..8c279c23f618f2312ddadad34f497426cf6312d6 100644 GIT binary patch delta 67 zcmZoMXfc=|#>B`mu~2NHo+2aj#DLw5%#(ST%s1OJpJ3U1fcX#OW_AvK4xp0F8=1c| VPv#e~g1?m;q{`5YGSr delta 290 zcmZoMXfc=|#>B)qu~2NHo+2aL#DLw44=^$^vQ6e;G#8gFvu}@FoXbM z0E06_4p2ub(2x=!8)R4-ke?2;q6o=?VmxMxL(O&u8V@#H6szH`Km&__78Kzzs&%so k<8_wJ>>T_Yz!2EHk?}k8WPTA#4o09CKt^v45ZS^E08f@fh5!Hn diff --git a/Sources/SKHTTPClient/SKHTTPClient.swift b/Sources/SKHTTPClient/SKHTTPClient.swift index 630e016..50bef1d 100644 --- a/Sources/SKHTTPClient/SKHTTPClient.swift +++ b/Sources/SKHTTPClient/SKHTTPClient.swift @@ -51,9 +51,7 @@ import Foundation guard let statusCode = (urlResponse as? HTTPURLResponse)?.statusCode else { completion(nil, HTTPClientError(type: .invalidResponse)) ; return } if self.printResponse { - print("URL : \(request.url?.absoluteString ?? "-")") - print("Status Code : \(statusCode)") - print(data?.prettyPrintedJSONString ?? "unable to print json-response") + self.printResponse(request, statusCode: statusCode, responseData: data) } guard Double(statusCode / 200) < 1.5 else { // all status codes begining with 2 are successfull @@ -83,3 +81,18 @@ import Foundation }.resume() } } + +// MARK: - Helpers + +extension HTTPClient { + + private func printResponse(_ request: URLRequest, statusCode: Int, responseData: Data?) { + print("🌍 - Network Call : \(request.httpMethod ?? "-") -> \(request.url?.absoluteString ?? "-")") + let isNetworkCallSuccesfull: Bool = Double(statusCode / 200) < 1.5 + let statusCodeEmoji: String = isNetworkCallSuccesfull ? "✅" : "❌" + print("\(statusCodeEmoji) - Status Code : \(statusCode)") + + print(responseData?.prettyPrintedJSONString ?? "unable to print json-response") + print("\n") + } +}