Created
February 13, 2016 13:50
-
-
Save vburojevic/3facab4c12da73d8e938 to your computer and use it in GitHub Desktop.
RxAlamofire logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
import RxAlamofire | |
extension Alamofire.Request { | |
public func logRequest() -> Self { | |
print(terminator:"\n") | |
print("🚀 REQUEST: \(self.request!.URL!)", terminator:"\n") | |
debugPrint(self, terminator:"\n\n") | |
_ = rx_responseJSON() | |
.subscribe( | |
onNext: { (response, json) in | |
print("✅ RESPONSE:", terminator:"\n") | |
debugPrint(response, terminator:"\n") | |
debugPrint(json, terminator: "\n\n") | |
}, | |
onError: { [weak self] errorType in | |
print("❌ RESPONSE ERROR: \(errorType)", terminator:"\n") | |
debugPrint(self?.response, terminator:"\n\n") | |
}) | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment