class Ey::Logger::Faraday
Attributes
adapter[R]
Public Class Methods
new(app, options={})
click to toggle source
# File lib/ey/logger/faraday.rb, line 5 def initialize(app, options={}) @app = app options[:prefix] ||= "ey.faraday" @adapter = Ey::Logger.new(options) end
Public Instance Methods
call(request_env)
click to toggle source
# File lib/ey/logger/faraday.rb, line 13 def call(request_env) # request phase # :method - :get, :post, ... # :url - URI for the current request; also contains GET parameters # :body - POST parameters for :post/:put requests # :request_headers adapter.call(tag: "request", data: { :method => request_env.method, :url => request_env.url.to_s, :headers => request_env.request_headers, :body => request_env.body, }) @app.call(request_env).on_complete do |response_env| # response phase # :status - HTTP response status code, such as 200 # :body - the response body # :response_headers adapter.call(tag: "response", data: { :method => request_env.method, :url => request_env.url.to_s, :status => response_env.status, :body => response_env.body, :headers => response_env.response_headers, }) end end