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 +4 -4
- data/.gitignore +13 -25
- data/.travis.yml +13 -4
- data/Appraisals +5 -1
- data/CHANGELOG.md +23 -0
- data/LICENSE.txt +17 -18
- data/README.md +7 -5
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/faraday-detailed_logger.gemspec +10 -8
- data/gemfiles/faraday_canary.gemfile +7 -0
- data/gemfiles/{faraday_current.gemfile → faraday_release.gemfile} +0 -0
- data/lib/faraday/detailed_logger/middleware.rb +11 -1
- data/lib/faraday/detailed_logger/version.rb +1 -1
- metadata +31 -16
- data/spec/faraday/detailed_logger/middleware_spec.rb +0 -87
- data/spec/spec_helper.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2977037d8f6588227b30e82bfd0c25e184c35fd
|
4
|
+
data.tar.gz: 26ebc6311679aef4db54a2d3eeeebc1a8415e22a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 565f8d0ecb8a9b1e055c89b27e9692298f636fc525b4d077a3b7b08ebfde533294dd9a7b1f21e86425810b3168ef91f7b7e10cf921bbb358345e2d57b34fc0c9
|
7
|
+
data.tar.gz: e2e0d6698cc0681ed37022bb75df70832b0470c7fb4914c09f8101e6caaa2b1f51f730a44ab76af8f204710bf5fc450c1a965b7b1f45f878f478c0220920f6f1
|
data/.gitignore
CHANGED
@@ -1,25 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
data/.travis.yml
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
-
|
1
|
+
before_install: gem install bundler -v 1.12.5
|
2
2
|
cache: bundler
|
3
|
-
|
4
|
-
-
|
5
|
-
-
|
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
data/CHANGELOG.md
ADDED
@@ -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
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2014 Envy Labs, LLC
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
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
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
data/bin/console
ADDED
@@ -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
|
data/bin/setup
ADDED
@@ -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.
|
18
|
-
spec.
|
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.
|
22
|
+
spec.add_runtime_dependency "faraday"
|
22
23
|
|
23
|
-
spec.add_development_dependency "appraisal", "~>
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.
|
25
|
-
spec.add_development_dependency "
|
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
|
File without changes
|
@@ -56,7 +56,8 @@ module Faraday
|
|
56
56
|
# Returns nothing.
|
57
57
|
#
|
58
58
|
def on_complete(env)
|
59
|
-
|
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
|
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.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Envy Labs
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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: '
|
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: '
|
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.
|
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.
|
54
|
+
version: '1.12'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
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/
|
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
|
-
|
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.
|
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
|
-
|
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
|
data/spec/spec_helper.rb
DELETED
@@ -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
|