lib/lazy_resource/request.rb in lazy_resource-0.3.0 vs lib/lazy_resource/request.rb in lazy_resource-0.3.2
- old
+ new
@@ -19,13 +19,18 @@
self
end
def on_complete_proc
Proc.new do |response|
+ log_response(response) if LazyResource.debug && LazyResource.logger
@response = response
handle_errors unless SUCCESS_STATUSES.include?(@response.code)
parse
end
+ end
+
+ def log_response(response)
+ LazyResource.logger.info "\t[#{response.code}](#{((response.time || 0) * 1000).ceil}ms): #{self.url}"
end
def parse
unless self.response.body.nil? || self.response.body == ''
@resource.load(JSON.parse(self.response.body))