Skip to content

Commit

Permalink
Ride request headers in logging (hopefully not too noisy)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyledrake committed Oct 10, 2011
1 parent 535dec8 commit 026f942
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/geoloqi/session.rb
Expand Up @@ -73,21 +73,23 @@ def run(meth, path, query=nil, headers={})

def execute(meth, path, query=nil, headers={})
query = Rack::Utils.parse_query query if query.is_a?(String)
headers = headers.merge! default_headers

raw = @connection.send(meth) do |req|
req.url "/#{Geoloqi.api_version.to_s}/#{path.gsub(/^\//, '')}"
req.headers = headers.merge! default_headers

req.headers = headers
if query
meth == :get ? req.params = query : req.body = query.to_json
end
end

if @config.logger
@config.logger.print "### Geoloqi::Session - #{meth.to_s.upcase} #{path}"
@config.logger.print "?#{Rack::Utils.build_query query}" unless query.nil?
@config.logger.puts "\n### Status: #{raw.status}\n### Headers: #{raw.headers.inspect}\n### Body: #{raw.body}"
@config.logger.puts "\n### Request Headers: #{headers.inspect}"
@config.logger.puts "### Status: #{raw.status}\n### Headers: #{raw.headers.inspect}\n### Body: #{raw.body}"
end

Response.new raw.status, raw.headers, raw.body
end

Expand Down

0 comments on commit 026f942

Please sign in to comment.