Sha256: 1852cd4a5ccf23efed3abaa969cfc02938210589782dd31aa74e1ea00ca8c8ac

Contents?: true

Size: 407 Bytes

Versions: 2

Compression:

Stored size: 407 Bytes

Contents

require "logger"
class ApiClient::Connection::Middlewares::Request::Logger < Faraday::Middleware

  def call(env)
    time    = Time.now
    returns = @app.call(env)
    taken   = Time.now - time
    @logger.info "#{env[:method].upcase} #{env[:url]}: #{"%.4f" % taken} seconds"
    returns
  end

  def initialize(app, logger = nil)
    @logger = logger || ::Logger.new(STDOUT)
    @app    = app
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_client-0.1.1 lib/api_client/connection/middlewares/request/logger.rb
api_client-0.1.0 lib/api_client/connection/middlewares/request/logger.rb