faraday-detailed_logger 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40a4b8eee431c057e71e75cbea811d3637c13939
4
- data.tar.gz: fb290d8d2af9104d3a94b3fde042678e988076bd
3
+ metadata.gz: e2977037d8f6588227b30e82bfd0c25e184c35fd
4
+ data.tar.gz: 26ebc6311679aef4db54a2d3eeeebc1a8415e22a
5
5
  SHA512:
6
- metadata.gz: 044fe22fe6c4a0b692c6d342b661acbc80b3ac0481952ec7b194d960bf1a9d2ede75a2324ce53b3c9010e55dd9813445d26d967d9063c583ed565117daea0147
7
- data.tar.gz: f27298c2fb4966bb1348bc5e4d8a31ab9de30222c5f4939c5a717fe8b831d30243031b0c76a24388ec3372321ef18c2b8e1c4e4b56c50fcebb641343f26a9262
6
+ metadata.gz: 565f8d0ecb8a9b1e055c89b27e9692298f636fc525b4d077a3b7b08ebfde533294dd9a7b1f21e86425810b3168ef91f7b7e10cf921bbb358345e2d57b34fc0c9
7
+ data.tar.gz: e2e0d6698cc0681ed37022bb75df70832b0470c7fb4914c09f8101e6caaa2b1f51f730a44ab76af8f204710bf5fc450c1a965b7b1f45f878f478c0220920f6f1
data/.gitignore CHANGED
@@ -1,25 +1,13 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .ruby-gemset
6
- .ruby-version
7
- .yardoc
8
- Gemfile.lock
9
- gemfiles/*.gemfile.lock
10
- InstalledFiles
11
- _yardoc
12
- coverage
13
- doc/
14
- lib/bundler/man
15
- pkg
16
- rdoc
17
- spec/reports
18
- test/tmp
19
- test/version_tmp
20
- tmp
21
- *.bundle
22
- *.so
23
- *.o
24
- *.a
25
- mkmf.log
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ /.ruby-gemset
12
+ /.ruby-version
13
+ /gemfiles/*.gemfile.lock
@@ -1,7 +1,16 @@
1
- language: ruby
1
+ before_install: gem install bundler -v 1.12.5
2
2
  cache: bundler
3
- rvm:
4
- - 1.9.3
5
- - 2.1.1
3
+ gemfile:
4
+ - gemfiles/faraday_0.8.gemfile
5
+ - gemfiles/faraday_release.gemfile
6
+ - gemfiles/faraday_canary.gemfile
7
+ language: ruby
8
+ matrix:
9
+ fast_finish: true
10
+ allow_failures:
11
+ - gemfile: gemfiles/faraday_canary.gemfile
6
12
  notifications:
7
13
  email: false
14
+ rvm:
15
+ - 2.3.1
16
+ sudo: false
data/Appraisals CHANGED
@@ -2,6 +2,10 @@ appraise "faraday-0.8" do
2
2
  gem "faraday", "~> 0.8.0"
3
3
  end
4
4
 
5
- appraise "faraday-current" do
5
+ appraise "faraday-release" do
6
6
  gem "faraday"
7
7
  end
8
+
9
+ appraise "faraday-canary" do
10
+ gem "faraday", github: "lostisland/faraday"
11
+ end
@@ -0,0 +1,23 @@
1
+ # Faraday::DetailedLogger changelog
2
+
3
+ [![Gem Version](https://img.shields.io/gem/v/faraday-detailed_logger.svg)](http://rubygems.org/gems/faraday-detailed_logger)
4
+ [![Build Status](https://img.shields.io/travis/envylabs/faraday-detailed_logger/master.svg)](https://travis-ci.org/envylabs/faraday-detailed_logger)
5
+ [![Code Climate](https://img.shields.io/codeclimate/github/envylabs/faraday-detailed_logger.svg)](https://codeclimate.com/github/envylabs/faraday-detailed_logger)
6
+ [![Coverage Status](https://img.shields.io/coveralls/envylabs/faraday-detailed_logger.svg)](https://coveralls.io/r/envylabs/faraday-detailed_logger)
7
+ [![Dependency Status](https://gemnasium.com/envylabs/faraday-detailed_logger.svg)](https://gemnasium.com/envylabs/faraday-detailed_logger)
8
+
9
+ ## [HEAD][] / unreleased
10
+
11
+ * No significant changes.
12
+
13
+ ## [1.1.0][] / 2016-06-15
14
+
15
+ * Log HTTP 4XX and HTTP 5XX responses at a WARN level.
16
+
17
+ ## [1.0.0][] / 2014-07-02
18
+
19
+ * Stable release.
20
+
21
+ [1.0.0]: https://github.com/envylabs/faraday-detailed_logger/tree/v1.0.0
22
+ [1.1.0]: https://github.com/envylabs/faraday-detailed_logger/compare/v1.0.0...v1.1.0
23
+ [HEAD]: https://github.com/envylabs/faraday-detailed_logger/compare/v1.1.0...master
@@ -1,22 +1,21 @@
1
- Copyright (c) 2014 Envy Labs, LLC
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2014 Envy Labs, LLC
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
15
14
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Gem Version](https://img.shields.io/gem/v/faraday-detailed_logger.svg)](http://rubygems.org/gems/faraday-detailed_logger)
4
4
  [![Build Status](https://img.shields.io/travis/envylabs/faraday-detailed_logger/master.svg)](https://travis-ci.org/envylabs/faraday-detailed_logger)
5
5
  [![Code Climate](https://img.shields.io/codeclimate/github/envylabs/faraday-detailed_logger.svg)](https://codeclimate.com/github/envylabs/faraday-detailed_logger)
6
+ [![Coverage Status](https://img.shields.io/coveralls/envylabs/faraday-detailed_logger.svg)](https://coveralls.io/r/envylabs/faraday-detailed_logger)
6
7
  [![Dependency Status](https://gemnasium.com/envylabs/faraday-detailed_logger.svg)](https://gemnasium.com/envylabs/faraday-detailed_logger)
7
8
 
8
9
  A Faraday middleware used for providing debug- and info-level logging
@@ -139,8 +140,9 @@ headers and body are logged at a DEBUG level.
139
140
 
140
141
  ## Contributing
141
142
 
142
- 1. Fork it ( https://github.com/envylabs/faraday-detailed_logger/fork )
143
- 2. Create your feature branch (`git checkout -b my-new-feature`)
144
- 3. Commit your changes (`git commit -am 'Add some feature'`)
145
- 4. Push to the branch (`git push origin my-new-feature`)
146
- 5. Create a new Pull Request
143
+ Bug reports and pull requests are welcome on GitHub at https://github.com/envylabs/faraday-detailed_logger.
144
+
145
+
146
+ ## License
147
+
148
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -2,4 +2,5 @@ require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
+
5
6
  task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "faraday/detailed_logger"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -8,20 +8,22 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Faraday::DetailedLogger::VERSION
9
9
  spec.authors = ["Envy Labs"]
10
10
  spec.email = [""]
11
+
11
12
  spec.summary = %q{A detailed request and response logger for Faraday.}
12
13
  spec.description = %q{A Faraday middleware for logging request and response activity including method, URI, headers, and body at varying log levels.}
13
- spec.homepage = ""
14
+ spec.homepage = "https://github.com/envylabs/faraday-detailed_logger"
14
15
  spec.license = "MIT"
15
16
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
20
  spec.require_paths = ["lib"]
20
21
 
21
- spec.add_dependency "faraday"
22
+ spec.add_runtime_dependency "faraday"
22
23
 
23
- spec.add_development_dependency "appraisal", "~> 1.0"
24
- spec.add_development_dependency "bundler", "~> 1.6"
25
- spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "appraisal", "~> 2.0"
25
+ spec.add_development_dependency "bundler", "~> 1.12"
26
+ spec.add_development_dependency "coveralls"
27
+ spec.add_development_dependency "rake", "~> 11.0"
26
28
  spec.add_development_dependency "rspec", "~> 3.0"
27
29
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "faraday", :github => "lostisland/faraday"
6
+
7
+ gemspec :path => "../"
@@ -56,7 +56,8 @@ module Faraday
56
56
  # Returns nothing.
57
57
  #
58
58
  def on_complete(env)
59
- @logger.info(@progname) { "HTTP #{env[:status]}" }
59
+ status = env[:status]
60
+ log_response_status(@progname, status) { "HTTP #{status}" }
60
61
  @logger.debug(@progname) { curl_output(env[:response_headers], env[:body]).inspect }
61
62
  end
62
63
 
@@ -68,6 +69,15 @@ module Faraday
68
69
  string = headers.collect { |k,v| "#{k}: #{v}" }.join("\n")
69
70
  string + "\n\n#{body}"
70
71
  end
72
+
73
+ def log_response_status(progname, status, &block)
74
+ case status
75
+ when 200..399
76
+ @logger.info(progname, &block)
77
+ else
78
+ @logger.warn(progname, &block)
79
+ end
80
+ end
71
81
  end
72
82
  end
73
83
  end
@@ -1,5 +1,5 @@
1
1
  module Faraday
2
2
  module DetailedLogger
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-detailed_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Envy Labs
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -30,30 +30,30 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '2.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.6'
47
+ version: '1.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.6'
54
+ version: '1.12'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '11.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '11.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -92,19 +106,21 @@ files:
92
106
  - ".rspec"
93
107
  - ".travis.yml"
94
108
  - Appraisals
109
+ - CHANGELOG.md
95
110
  - Gemfile
96
111
  - LICENSE.txt
97
112
  - README.md
98
113
  - Rakefile
114
+ - bin/console
115
+ - bin/setup
99
116
  - faraday-detailed_logger.gemspec
100
117
  - gemfiles/faraday_0.8.gemfile
101
- - gemfiles/faraday_current.gemfile
118
+ - gemfiles/faraday_canary.gemfile
119
+ - gemfiles/faraday_release.gemfile
102
120
  - lib/faraday/detailed_logger.rb
103
121
  - lib/faraday/detailed_logger/middleware.rb
104
122
  - lib/faraday/detailed_logger/version.rb
105
- - spec/faraday/detailed_logger/middleware_spec.rb
106
- - spec/spec_helper.rb
107
- homepage: ''
123
+ homepage: https://github.com/envylabs/faraday-detailed_logger
108
124
  licenses:
109
125
  - MIT
110
126
  metadata: {}
@@ -124,10 +140,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
140
  version: '0'
125
141
  requirements: []
126
142
  rubyforge_project:
127
- rubygems_version: 2.3.0
143
+ rubygems_version: 2.5.1
128
144
  signing_key:
129
145
  specification_version: 4
130
146
  summary: A detailed request and response logger for Faraday.
131
- test_files:
132
- - spec/faraday/detailed_logger/middleware_spec.rb
133
- - spec/spec_helper.rb
147
+ test_files: []
148
+ has_rdoc:
@@ -1,87 +0,0 @@
1
- require "spec_helper"
2
-
3
- require "logger"
4
- require "stringio"
5
-
6
- describe Faraday::DetailedLogger::Middleware do
7
- it "passes through the given progname to the logger" do
8
- logger = Logger.new(log = StringIO.new)
9
-
10
- expect {
11
- connection(logger, "TESTPROGNAME").get("/temaki")
12
- }.to change {
13
- log.rewind
14
- !!(log.read =~/\bTESTPROGNAME\b/)
15
- }.to(true)
16
- end
17
-
18
- it "logs the request method at an INFO level" do
19
- logger = Logger.new(log = StringIO.new)
20
-
21
- connection(logger).get("/temaki")
22
- log.rewind
23
- expect(log.read).to match(/\bINFO\b.+\bGET\b/)
24
- end
25
-
26
- it "logs the request URI at an INFO level" do
27
- logger = Logger.new(log = StringIO.new)
28
-
29
- connection(logger).get("/temaki")
30
- log.rewind
31
- expect(log.read).to match(/\bINFO\b.+\bhttp:\/\/sushi.com\/temaki\b/)
32
- end
33
-
34
- it "logs a cURL-like request package at a DEBUG level" do
35
- logger = Logger.new(log = StringIO.new)
36
-
37
- connection(logger).post("/nigirizushi", {"body" => "content"}, {:user_agent => "Faraday::DetailedLogger"})
38
- log.rewind
39
- curl = <<-CURL.strip
40
- User-Agent: Faraday::DetailedLogger
41
- Content-Type: application/x-www-form-urlencoded
42
-
43
- body=content
44
- CURL
45
- expect(log.read).to match(/\bDEBUG\b.+#{Regexp.escape(curl.inspect)}/)
46
- end
47
-
48
- it "logs the response status code at an INFO level" do
49
- logger = Logger.new(log = StringIO.new)
50
-
51
- connection(logger).get("/temaki")
52
- log.rewind
53
- expect(log.read).to match(/\bINFO\b.+\bHTTP 200\b/)
54
- end
55
-
56
- it "logs a cURL-like response package at a DEBUG level" do
57
- logger = Logger.new(log = StringIO.new)
58
-
59
- connection(logger).post("/nigirizushi")
60
- log.rewind
61
- curl = <<-CURL.strip
62
- Content-Type: application/json
63
-
64
- {"order_id":"1"}
65
- CURL
66
- expect(log.read).to match(/\bDEBUG\b.+#{Regexp.escape(curl.inspect)}/)
67
- end
68
-
69
-
70
- private
71
-
72
-
73
- def connection(logger = nil, progname = nil)
74
- Faraday.new(:url => "http://sushi.com") do |builder|
75
- builder.request(:url_encoded)
76
- builder.response(:detailed_logger, logger, progname)
77
- builder.adapter(:test) do |stub|
78
- stub.get("/temaki") {
79
- [200, {"Content-Type" => "text/plain"}, "temaki"]
80
- }
81
- stub.post("/nigirizushi") {
82
- [200, {"Content-Type" => "application/json"}, "{\"order_id\":\"1\"}"]
83
- }
84
- end
85
- end
86
- end
87
- end
@@ -1,25 +0,0 @@
1
- require "bundler/setup"
2
- require "faraday/detailed_logger"
3
-
4
- RSpec.configure do |config|
5
- config.filter_run :focus
6
- config.run_all_when_everything_filtered = true
7
-
8
- if config.files_to_run.one?
9
- config.default_formatter = 'doc'
10
- end
11
-
12
- config.profile_examples = 10
13
- config.order = :random
14
-
15
- Kernel.srand config.seed
16
-
17
- config.expect_with :rspec do |expectations|
18
- expectations.syntax = :expect
19
- end
20
-
21
- config.mock_with :rspec do |mocks|
22
- mocks.syntax = :expect
23
- mocks.verify_partial_doubles = true
24
- end
25
- end