faraday-detailed_logger 2.0.0 → 2.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: 39391a10ebf6f5c1e3afd4a16142b4a7a5cf44de
4
- data.tar.gz: 7c339da08c5eba109844ec73cc5fe555b7a32f06
3
+ metadata.gz: 9de23200c017205fc17035dbc8ab4cd8e373c7df
4
+ data.tar.gz: 9bc2d6b56c9755f8968423a04ffe7e32b1ceb1fd
5
5
  SHA512:
6
- metadata.gz: 5c4eb19555cb5d2062e6574f06c20c2104351ea4416912012296e323cc2c6c2b6f5a3342c6771cf350b7ddd5a997cc30a00e29a3d66298ff92e9afabb42834c9
7
- data.tar.gz: 04c930843a10137ddccf41c45530519c25eebbd7e38e04e18f19ff207cb1686b449461a23df23ba01855a822502920f693c43ea925cf7c6d8c3babf35579794c
6
+ metadata.gz: c19accdf9dd31ce178bfc1e426f2ce7bbf733a407a0b2671c3667d2b6e6c5a9f1a14496fbd0909eaac3d5d076934a4e1baed906ca31e61d3b74b9e64b6db8f59
7
+ data.tar.gz: 8f64e8042ce7a1b171e81ffa6f6d582fcf31586b87a89589eb46a76f17008b38641f88a133d89f7df324b81053aa27f87b0a925c09b49de9ffe715f2dbe20c6a
@@ -0,0 +1,2 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
@@ -0,0 +1,247 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "vendor/**/*"
4
+ - "db/schema.rb"
5
+ UseCache: false
6
+ Style/BracesAroundHashParameters:
7
+ EnforcedStyle: braces
8
+ Style/CollectionMethods:
9
+ Description: Preferred collection methods.
10
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
11
+ Enabled: true
12
+ PreferredMethods:
13
+ collect: map
14
+ collect!: map!
15
+ find: detect
16
+ find_all: select
17
+ reduce: inject
18
+ Style/DotPosition:
19
+ Description: Checks the position of the dot in multi-line method calls.
20
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
21
+ Enabled: true
22
+ EnforcedStyle: trailing
23
+ SupportedStyles:
24
+ - leading
25
+ - trailing
26
+ Style/FileName:
27
+ Description: Use snake_case for source file names.
28
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
29
+ Enabled: false
30
+ Exclude: []
31
+ Style/GuardClause:
32
+ Description: Check for conditionals that can be replaced with guard clauses
33
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
34
+ Enabled: false
35
+ MinBodyLength: 1
36
+ Style/IfUnlessModifier:
37
+ Description: Favor modifier if/unless usage when you have a single-line body.
38
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
39
+ Enabled: false
40
+ MaxLineLength: 80
41
+ Style/IndentHash:
42
+ EnforcedStyle: consistent
43
+ Style/OptionHash:
44
+ Description: Don't use option hashes when you can use keyword arguments.
45
+ Enabled: false
46
+ Style/PercentLiteralDelimiters:
47
+ Description: Use `%`-literal delimiters consistently
48
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
49
+ Enabled: false
50
+ PreferredDelimiters:
51
+ "%": "()"
52
+ "%i": "()"
53
+ "%q": "()"
54
+ "%Q": "()"
55
+ "%r": "{}"
56
+ "%s": "()"
57
+ "%w": "()"
58
+ "%W": "()"
59
+ "%x": "()"
60
+ Style/PredicateName:
61
+ Description: Check the names of predicate methods.
62
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
63
+ Enabled: true
64
+ NamePrefix:
65
+ - is_
66
+ - has_
67
+ - have_
68
+ NamePrefixBlacklist:
69
+ - is_
70
+ Exclude:
71
+ - spec/**/*
72
+ Style/RaiseArgs:
73
+ Description: Checks the arguments passed to raise/fail.
74
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
75
+ Enabled: false
76
+ EnforcedStyle: exploded
77
+ SupportedStyles:
78
+ - compact
79
+ - exploded
80
+ Style/SignalException:
81
+ Description: Checks for proper usage of fail and raise.
82
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
83
+ Enabled: false
84
+ EnforcedStyle: semantic
85
+ SupportedStyles:
86
+ - only_raise
87
+ - only_fail
88
+ - semantic
89
+ Style/SingleLineBlockParams:
90
+ Description: Enforces the names of some block params.
91
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
92
+ Enabled: false
93
+ Methods:
94
+ - reduce:
95
+ - a
96
+ - e
97
+ - inject:
98
+ - a
99
+ - e
100
+ Style/SingleLineMethods:
101
+ Description: Avoid single-line methods.
102
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
103
+ Enabled: false
104
+ AllowIfMethodIsEmpty: true
105
+ Style/StringLiterals:
106
+ Description: Checks if uses of quotes match the configured preference.
107
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
108
+ Enabled: true
109
+ EnforcedStyle: double_quotes
110
+ SupportedStyles:
111
+ - single_quotes
112
+ - double_quotes
113
+ Style/StringLiteralsInInterpolation:
114
+ Description: Checks if uses of quotes inside expressions in interpolated strings
115
+ match the configured preference.
116
+ Enabled: true
117
+ EnforcedStyle: single_quotes
118
+ SupportedStyles:
119
+ - single_quotes
120
+ - double_quotes
121
+ Style/TrailingCommaInArguments:
122
+ Description: 'Checks for trailing comma in argument lists.'
123
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
124
+ Enabled: false
125
+ EnforcedStyleForMultiline: no_comma
126
+ SupportedStyles:
127
+ - comma
128
+ - consistent_comma
129
+ - no_comma
130
+ Style/TrailingCommaInLiteral:
131
+ Description: 'Checks for trailing comma in array and hash literals.'
132
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
133
+ Enabled: false
134
+ EnforcedStyleForMultiline: no_comma
135
+ SupportedStyles:
136
+ - comma
137
+ - consistent_comma
138
+ - no_comma
139
+ Metrics/AbcSize:
140
+ Description: A calculated magnitude based on number of assignments, branches, and
141
+ conditions.
142
+ Enabled: false
143
+ Max: 15
144
+ Metrics/ClassLength:
145
+ Description: Avoid classes longer than 100 lines of code.
146
+ Enabled: false
147
+ CountComments: false
148
+ Max: 100
149
+ Metrics/ModuleLength:
150
+ CountComments: false
151
+ Max: 100
152
+ Description: Avoid modules longer than 100 lines of code.
153
+ Enabled: false
154
+ Metrics/CyclomaticComplexity:
155
+ Description: A complexity metric that is strongly correlated to the number of test
156
+ cases needed to validate a method.
157
+ Enabled: false
158
+ Max: 6
159
+ Metrics/MethodLength:
160
+ Description: Avoid methods longer than 10 lines of code.
161
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
162
+ Enabled: false
163
+ CountComments: false
164
+ Max: 10
165
+ Metrics/ParameterLists:
166
+ Description: Avoid parameter lists longer than three or four parameters.
167
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
168
+ Enabled: false
169
+ Max: 5
170
+ CountKeywordArgs: true
171
+ Metrics/PerceivedComplexity:
172
+ Description: A complexity metric geared towards measuring complexity for a human
173
+ reader.
174
+ Enabled: false
175
+ Max: 7
176
+ Lint/AssignmentInCondition:
177
+ Description: Don't use assignment in conditions.
178
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
179
+ Enabled: false
180
+ AllowSafeAssignment: true
181
+ Style/InlineComment:
182
+ Description: Avoid inline comments.
183
+ Enabled: false
184
+ Style/AccessorMethodName:
185
+ Description: Check the naming of accessor methods for get_/set_.
186
+ Enabled: false
187
+ Style/Alias:
188
+ Description: Use alias_method instead of alias.
189
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
190
+ Enabled: false
191
+ Style/Documentation:
192
+ Description: Document classes and non-namespace modules.
193
+ Enabled: false
194
+ Style/DoubleNegation:
195
+ Description: Checks for uses of double negation (!!).
196
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
197
+ Enabled: false
198
+ Style/EachWithObject:
199
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
200
+ Enabled: false
201
+ Style/EmptyLiteral:
202
+ Description: Prefer literals to Array.new/Hash.new/String.new.
203
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
204
+ Enabled: false
205
+ Style/ModuleFunction:
206
+ Description: Checks for usage of `extend self` in modules.
207
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
208
+ Enabled: false
209
+ Style/OneLineConditional:
210
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
211
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
212
+ Enabled: false
213
+ Style/PerlBackrefs:
214
+ Description: Avoid Perl-style regex back references.
215
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
216
+ Enabled: false
217
+ Style/Send:
218
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
219
+ may overlap with existing methods.
220
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
221
+ Enabled: false
222
+ Style/SpecialGlobalVars:
223
+ Description: Avoid Perl-style global variables.
224
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
225
+ Enabled: false
226
+ Style/VariableInterpolation:
227
+ Description: Don't interpolate global, instance and class variables directly in
228
+ strings.
229
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
230
+ Enabled: false
231
+ Style/WhenThen:
232
+ Description: Use when x then ... for one-line cases.
233
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
234
+ Enabled: false
235
+ Lint/EachWithObjectArgument:
236
+ Description: Check for immutable argument given to each_with_object.
237
+ Enabled: true
238
+ Lint/HandleExceptions:
239
+ Description: Don't suppress exception.
240
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
241
+ Enabled: false
242
+ Lint/LiteralInCondition:
243
+ Description: Checks of literals used in conditions.
244
+ Enabled: false
245
+ Lint/LiteralInInterpolation:
246
+ Description: Checks for literals used in interpolation.
247
+ Enabled: false
@@ -10,6 +10,10 @@
10
10
 
11
11
  * No significant changes.
12
12
 
13
+ ## [2.1.0][] / 2016-10-12
14
+
15
+ * Catch StandardError exceptions to log and re-raise them.
16
+
13
17
  ## [2.0.0][] / 2016-07-08
14
18
 
15
19
  * Remove Logger `progname` support/configuration. Varying the progname appears
@@ -33,4 +37,5 @@
33
37
  [1.0.0]: https://github.com/envylabs/faraday-detailed_logger/tree/v1.0.0
34
38
  [1.1.0]: https://github.com/envylabs/faraday-detailed_logger/compare/v1.0.0...v1.1.0
35
39
  [2.0.0]: https://github.com/envylabs/faraday-detailed_logger/compare/v1.1.0...v2.0.0
36
- [HEAD]: https://github.com/envylabs/faraday-detailed_logger/compare/v2.0.0...master
40
+ [2.1.0]: https://github.com/envylabs/faraday-detailed_logger/compare/v2.0.0...v2.1.0
41
+ [HEAD]: https://github.com/envylabs/faraday-detailed_logger/compare/v2.1.0...master
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in faraday-detailed_logger.gemspec
1
+ source "https://rubygems.org"
4
2
  gemspec
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task({ default: :spec })
@@ -1,22 +1,28 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'faraday/detailed_logger/version'
4
+ require "faraday/detailed_logger/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "faraday-detailed_logger"
8
- spec.version = Faraday::DetailedLogger::VERSION
9
- spec.authors = ["Envy Labs"]
10
- spec.email = [""]
7
+ spec.name = "faraday-detailed_logger"
8
+ spec.version = Faraday::DetailedLogger::VERSION
9
+ spec.authors = ["Envy Labs"]
10
+ spec.email = [""]
11
11
 
12
- spec.summary = %q{A detailed request and response logger for Faraday.}
13
- spec.description = %q{A Faraday middleware for logging request and response activity including method, URI, headers, and body at varying log levels.}
14
- spec.homepage = "https://github.com/envylabs/faraday-detailed_logger"
15
- spec.license = "MIT"
12
+ spec.summary = "A detailed request and response logger for Faraday."
13
+ spec.description = %(
14
+ A Faraday middleware for logging request and response activity including
15
+ method, URI, headers, and body at varying log levels.
16
+ )
17
+ spec.homepage = "https://github.com/envylabs/faraday-detailed_logger"
18
+ spec.license = "MIT"
16
19
 
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) }
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ }
23
+
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
26
  spec.require_paths = ["lib"]
21
27
 
22
28
  spec.add_runtime_dependency "faraday"
@@ -14,13 +14,11 @@ module Faraday
14
14
  # greater level, this is not a concern.
15
15
  #
16
16
  class Middleware < Faraday::Response::Middleware
17
-
18
17
  def self.default_logger
19
18
  require "logger"
20
- ::Logger.new(STDOUT)
19
+ ::Logger.new($stdout)
21
20
  end
22
21
 
23
-
24
22
  # Public: Initialize a new Logger middleware.
25
23
  #
26
24
  # app - A Faraday-compatible middleware stack or application.
@@ -46,9 +44,12 @@ module Faraday
46
44
  def call(env)
47
45
  logger.tagged(*tags) do
48
46
  logger.info { "#{env[:method].upcase} #{env[:url]}" }
49
- logger.debug { curl_output(env[:request_headers], env[:body]).inspect }
47
+ logger.debug { curl_request_output(env) }
50
48
  end
51
49
  super
50
+ rescue
51
+ logger.error { "#{$!.class.name} - #{$!.message} (#{$!.backtrace.first})" }
52
+ raise
52
53
  end
53
54
 
54
55
  # Internal: Used by Faraday as a callback hook to process a network
@@ -63,19 +64,25 @@ module Faraday
63
64
 
64
65
  logger.tagged(*tags) do
65
66
  log_response_status(status) { "HTTP #{status}" }
66
- logger.debug { curl_output(env[:response_headers], env[:body]).inspect }
67
+ logger.debug { curl_response_output(env) }
67
68
  end
68
69
  end
69
70
 
70
-
71
71
  private
72
72
 
73
-
74
73
  attr_reader :logger
75
74
  attr_reader :tags
76
75
 
76
+ def curl_request_output(env)
77
+ curl_output(env[:request_headers], env[:body]).inspect
78
+ end
79
+
80
+ def curl_response_output(env)
81
+ curl_output(env[:response_headers], env[:body]).inspect
82
+ end
83
+
77
84
  def curl_output(headers, body)
78
- string = headers.collect { |k,v| "#{k}: #{v}" }.join("\n")
85
+ string = headers.map { |k, v| "#{k}: #{v}" }.join("\n")
79
86
  string + "\n\n#{body}"
80
87
  end
81
88
 
@@ -91,4 +98,6 @@ module Faraday
91
98
  end
92
99
  end
93
100
 
94
- Faraday::Response.register_middleware(:detailed_logger => Faraday::DetailedLogger::Middleware)
101
+ Faraday::Response.register_middleware({
102
+ detailed_logger: Faraday::DetailedLogger::Middleware
103
+ })
@@ -1,4 +1,4 @@
1
- require 'logger'
1
+ require "logger"
2
2
 
3
3
  module Faraday
4
4
  module DetailedLogger
@@ -10,7 +10,9 @@ module Faraday
10
10
  extend Forwardable
11
11
 
12
12
  module Formatter
13
- BLANK = lambda { |value| value.respond_to?(:empty?) ? !!value.empty? : !value }
13
+ BLANK = lambda do |value|
14
+ value.respond_to?(:empty?) ? !!value.empty? : !value
15
+ end
14
16
 
15
17
  def call(severity, timestamp, progname, msg)
16
18
  super(severity, timestamp, progname, "#{tags_text}#{msg}")
@@ -38,20 +40,20 @@ module Faraday
38
40
  end
39
41
 
40
42
  def current_tags
41
- @thread_key ||= "faraday_detailed_logger_tagged_logging_tags:#{object_id}".freeze
43
+ @thread_key ||= "faraday_detailed_logger_tags:#{object_id}".freeze
42
44
  Thread.current[@thread_key] ||= []
43
45
  end
44
46
 
45
47
  private
46
- def tags_text
47
- tags = current_tags
48
- if tags.any?
49
- tags.collect { |tag| "[#{tag}] " }.join
50
- end
48
+
49
+ def tags_text
50
+ tags = current_tags
51
+ if tags.any?
52
+ tags.map { |tag| "[#{tag}] " }.join
51
53
  end
54
+ end
52
55
  end
53
56
 
54
-
55
57
  def self.new(logger)
56
58
  unless logger.respond_to?(:tagged)
57
59
  logger.formatter ||= ::Logger::Formatter.new
@@ -1,5 +1,5 @@
1
1
  module Faraday
2
2
  module DetailedLogger
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0".freeze
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: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Envy Labs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-08 00:00:00.000000000 Z
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -94,8 +94,8 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
- description: A Faraday middleware for logging request and response activity including
98
- method, URI, headers, and body at varying log levels.
97
+ description: "\n A Faraday middleware for logging request and response activity
98
+ including\n method, URI, headers, and body at varying log levels.\n "
99
99
  email:
100
100
  - ''
101
101
  executables: []
@@ -103,7 +103,9 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - ".gitignore"
106
+ - ".hound.yml"
106
107
  - ".rspec"
108
+ - ".rubocop.yml"
107
109
  - ".travis.yml"
108
110
  - Appraisals
109
111
  - CHANGELOG.md
@@ -146,4 +148,3 @@ signing_key:
146
148
  specification_version: 4
147
149
  summary: A detailed request and response logger for Faraday.
148
150
  test_files: []
149
- has_rdoc: