Skip to content

Instantly share code, notes, and snippets.

@vburojevic
Created February 13, 2016 13:50
Show Gist options
  • Save vburojevic/3facab4c12da73d8e938 to your computer and use it in GitHub Desktop.
Save vburojevic/3facab4c12da73d8e938 to your computer and use it in GitHub Desktop.
RxAlamofire logging
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