No commit activity in last 3 years
No release in over 3 years
A Log Subscriber for Faraday clients
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0

Runtime

 Project Readme

Faraday Log Subscriber

A ActiveSupport::LogSubscriber to log HTTP requests made by a Faraday client instance.

Installation

Add it to your Gemfile:

gem 'faraday-log-subscriber'

Usage

You have to use the :instrumentation middleware from faraday_middleware to instrument your requests.

client = Faraday.new('https://api.github.com') do |builder|
  builder.use :instrumentation
  builder.adapter :net_http
end

client.get('repos/rails/rails')
# 'Faraday GET [200] (1026.9ms) https://api.github.com/repos/rails/rails'

faraday-http-cache integration

If you use the faraday-http-cache gem, an extra line will be logged regarding the cache status of the requested URL:

client = Faraday.new('https://api.github.com') do |builder|
  builder.use :instrumentation
  builder.use :http_cache, instrumenter: ActiveSupport::Notifications
  builder.adapter :net_http
end

client.get('repos/rails/rails')
client.get('repos/rails/rails')
# Faraday HTTP Cache [fresh] https://api.github.com/repos/rails/rails
# Faraday GET [200] (1.7ms) https://api.github.com/repos/rails/rails

License

Copyright (c) 2015 Plataformatec. See LICENSE file.