httplog 0.3.2 → 0.3.3

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: 62e9129265a40691ce4b016c6883c68d1d3962bb
4
- data.tar.gz: 33d81b489ec890a844ead102eb3b475a4e51fdbe
3
+ metadata.gz: 4458a32430545d16e4403483a77ef00b59d30c19
4
+ data.tar.gz: 5d334c5157c1da40ee45a1bd4c1142f1cd9c7636
5
5
  SHA512:
6
- metadata.gz: f418fcf451cc347381b112ba5433cd1f542e0fe402c137801c6eab9385959666b13e051b62784acf545d767b4a14e0d8994198d53b083e8101d898bcea5322aa
7
- data.tar.gz: a5061bd6083a73d61129fff9adea0070740490cbfcc231e40e989d295f8bee28f4d805626749eec9a783bd3c1d0aad02de207f3e6997d43baa2523202eeba323
6
+ metadata.gz: a3c3a854366b3d89ba534bfef525d488e7899cfd4935a11458aee52d06bd8a4bcc20d6b773795ba6432207aad2083baa96501c51cd9a07bd899f22139a7e469d
7
+ data.tar.gz: f09ac99eb6b33c119b55c3a496dc3c6c49a1431dc80bf2cac01f6e6a77f19fc46544de7ccf9b0892572a7cd18cb1e7ac046aeb90817fc62b3925b2d428e250f6
data/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/httplog.png)](http://badge.fury.io/rb/httplog) [![Build Status](https://travis-ci.org/trusche/httplog.svg?branch=master)](https://travis-ci.org/trusche/httplog) [![Code Climate](https://codeclimate.com/github/trusche/httplog.png)](https://codeclimate.com/github/trusche/httplog)
4
4
 
5
- Log outgoing HTTP requests made from your application.
6
- See the [blog post](http://trusche.github.com/blog/2011/09/29/logging-outgoing-http-requests/)
7
- for more details.
5
+ Log outgoing HTTP requests made from your application. Helps with debugging pesky API error responses, or just generally understanding what's going on under the hood.
8
6
 
9
7
  So far this gem works with the following ruby modules and libraries:
10
8
 
@@ -26,7 +24,8 @@ In theory, it should also work with any library built on top of these. But since
26
24
  the difference between theory and practice is bigger in practice than in theory, YMMV.
27
25
 
28
26
  This is very much a development and debugging tool; it is **not recommended** to
29
- use this in a production environment.
27
+ use this in a production environment as it is moneky-patching the respective HTTP implementations.
28
+ You have been warned - use at your own risk.
30
29
 
31
30
  ### Installation
32
31
 
@@ -159,3 +158,4 @@ Thanks to these fine folks for contributing pull requests:
159
158
  * [Chris Keele](https://github.com/christhekeele)
160
159
  * [Ryan Souza](https://github.com/ryansouza)
161
160
  * [Ilya Bondarenko](https://github.com/sedx)
161
+ * [Kostas Zacharakis](https://github.com/kzacharakis)
@@ -4,10 +4,13 @@ require "benchmark"
4
4
  require "colorize"
5
5
 
6
6
  module HttpLog
7
+ LOG_PREFIX = "[httplog] ".freeze
8
+
7
9
  DEFAULT_LOGGER = Logger.new($stdout)
8
10
  DEFAULT_OPTIONS = {
9
11
  :logger => DEFAULT_LOGGER,
10
12
  :severity => Logger::Severity::DEBUG,
13
+ :prefix => LOG_PREFIX,
11
14
  :log_connect => true,
12
15
  :log_request => true,
13
16
  :log_headers => false,
@@ -18,10 +21,12 @@ module HttpLog
18
21
  :compact_log => false,
19
22
  :url_whitelist_pattern => /.*/,
20
23
  :url_blacklist_pattern => nil,
21
- :color => false
24
+ :color => false,
25
+ :prefix_data_lines => false,
26
+ :prefix_response_lines => false,
27
+ :prefix_line_numbers => false
22
28
  }
23
29
 
24
- LOG_PREFIX = "[httplog] ".freeze
25
30
 
26
31
  class << self
27
32
  def options
@@ -46,7 +51,7 @@ module HttpLog
46
51
  # https://github.com/collectiveidea/delayed_job/commit/e7f5aa1ed806e61251bdb77daf25864eeb3aff59
47
52
  severities = Hash[*Logger::Severity.constants.enum_for(:each_with_index).collect{ |s, i| [i, s] }.flatten]
48
53
  severity = severities[options[:severity]].to_s.downcase
49
- options[:logger].send(severity, colorize(LOG_PREFIX + msg))
54
+ options[:logger].send(severity, colorize(prefix + msg))
50
55
  end
51
56
 
52
57
  def log_connection(host, port = nil)
@@ -99,13 +104,25 @@ module HttpLog
99
104
 
100
105
  data = utf_encoded(body.to_s, content_type)
101
106
 
102
- log("Response:\n#{data}")
107
+ if options[:prefix_response_lines]
108
+ log("Response:")
109
+ log_data_lines(data)
110
+ else
111
+ log("Response:\n#{data}")
112
+ end
113
+
103
114
  end
104
115
 
105
116
  def log_data(data)
106
117
  return if options[:compact_log] || !options[:log_data]
107
118
  data = utf_encoded(data.to_s)
108
- log("Data: #{data}")
119
+
120
+ if options[:prefix_data_lines]
121
+ log("Data:")
122
+ log_data_lines(data)
123
+ else
124
+ log("Data: #{data}")
125
+ end
109
126
  end
110
127
 
111
128
  def log_compact(method, uri, status, seconds)
@@ -134,5 +151,24 @@ module HttpLog
134
151
  content_type =~ /^text/ ||
135
152
  content_type =~ /^application/ && content_type != 'application/octet-stream'
136
153
  end
154
+
155
+ def log_data_lines(data)
156
+ data.each_line.with_index do |line, row|
157
+ if options[:prefix_line_numbers]
158
+ log("#{row + 1}: #{line.chomp}")
159
+ else
160
+ log(line.strip)
161
+ end
162
+ end
163
+ end
164
+
165
+ def prefix
166
+ if options[:prefix].respond_to?(:call)
167
+ options[:prefix].call
168
+ else
169
+ options[:prefix].to_s
170
+ end
171
+ end
172
+
137
173
  end
138
174
  end
@@ -1,4 +1,4 @@
1
1
  module HttpLog
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,167 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httplog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thilo Rusche
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-14 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: guard-rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '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
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
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
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thin
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: httpclient
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: httparty
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: faraday
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: excon
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.18.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.18.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: typhoeus
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: ethon
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: patron
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
@@ -182,56 +182,56 @@ dependencies:
182
182
  name: simplecov
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: log4r
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - '>='
199
+ - - ">="
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - '>='
206
+ - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rake
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - '>='
213
+ - - ">="
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - '>='
220
+ - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: colorize
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - '>='
227
+ - - ">="
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0'
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - '>='
234
+ - - ">="
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
237
  description: |-
@@ -242,6 +242,10 @@ executables: []
242
242
  extensions: []
243
243
  extra_rdoc_files: []
244
244
  files:
245
+ - MIT-LICENSE
246
+ - README.md
247
+ - Rakefile
248
+ - lib/httplog.rb
245
249
  - lib/httplog/adapters/ethon.rb
246
250
  - lib/httplog/adapters/excon.rb
247
251
  - lib/httplog/adapters/http.rb
@@ -250,10 +254,6 @@ files:
250
254
  - lib/httplog/adapters/patron.rb
251
255
  - lib/httplog/http_log.rb
252
256
  - lib/httplog/version.rb
253
- - lib/httplog.rb
254
- - MIT-LICENSE
255
- - Rakefile
256
- - README.md
257
257
  homepage: http://github.com/trusche/httplog
258
258
  licenses: []
259
259
  metadata: {}
@@ -263,17 +263,17 @@ require_paths:
263
263
  - lib
264
264
  required_ruby_version: !ruby/object:Gem::Requirement
265
265
  requirements:
266
- - - '>='
266
+ - - ">="
267
267
  - !ruby/object:Gem::Version
268
268
  version: '0'
269
269
  required_rubygems_version: !ruby/object:Gem::Requirement
270
270
  requirements:
271
- - - '>='
271
+ - - ">="
272
272
  - !ruby/object:Gem::Version
273
273
  version: '0'
274
274
  requirements: []
275
275
  rubyforge_project:
276
- rubygems_version: 2.0.14.1
276
+ rubygems_version: 2.5.1
277
277
  signing_key:
278
278
  specification_version: 4
279
279
  summary: Logs outgoing HTTP requests.