httplog 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 353b6a9275b66ee5ce0aacba9982356e48c6899f
4
- data.tar.gz: 661b69f4d6416877431a86431d2d0d5c50104e37
3
+ metadata.gz: 9d6a52cb676f03cfac9c5a01d9ccc94a90fa570c
4
+ data.tar.gz: e9df033e0168daa111145d05e325d727f88f17ac
5
5
  SHA512:
6
- metadata.gz: d661e463e0c8dfe40282ccd04cc1f17c73812cc055f3b11f1b224b7a167265a0a2bd23e43ab3d5e7ef370a7f83dd0974733c1a357571e1107f8001a4a8147b08
7
- data.tar.gz: facef46f56a01c451df3471ef21a439b8458049096630e997665372732c913db652255cfeb5e7ad9e4af12b269359237221db9bc8448488bf9dbe219f0bea86e
6
+ metadata.gz: 4547cfe819ebdd84ed7feca3c274d9311528146607a9e6ef3caa5e46800660038cda8e3954761b13658ae09ca0729028c95f64f0e5cc2563252350cd39c40815
7
+ data.tar.gz: 016c63b7476a75c47f0e6c0d8eab37d3a1e209d4438689b386f614f85499b42e03c4ac570c5430c6881d096101aecc8fc25908b79b34952d59a74d38bec734ca
data/README.md CHANGED
@@ -51,8 +51,9 @@ You can override the following default options:
51
51
  HttpLog.options[:log_status] = true
52
52
  HttpLog.options[:log_response] = true
53
53
  HttpLog.options[:log_benchmark] = true
54
- HttpLog.options[:compact_log] = false # setting this to true will make all "log_*" options redundant
55
-
54
+ HttpLog.options[:compact_log] = false # setting this to true will make
55
+ all "log_*" options redundant
56
+ HttpLog.options[:color] = false # (see below)
56
57
  # only log requests made to specified hosts (URLs)
57
58
  HttpLog.options[:url_whitelist_pattern] = /.*/
58
59
  # overrides whitelist
@@ -63,6 +64,12 @@ So if you want to use this in a Rails app:
63
64
  # config/initializers/httplog.rb
64
65
  HttpLog.options[:logger] = Rails.logger
65
66
 
67
+ You can colorize the output to make it stand out in your logfile:
68
+
69
+ HttpLog.options[:color] = {color: :black, background: :light_red}
70
+
71
+ For more color options see [colorize documentation](https://github.com/fazibear/colorize/blob/master/README.md)
72
+
66
73
  ### Example
67
74
 
68
75
  With the default configuration, the log output might look like this:
@@ -109,7 +116,7 @@ With the default configuration, the log output might look like this:
109
116
  D, [2012-11-22T18:39:46.033409 #12800] DEBUG -- : [httplog] Status: 200
110
117
  D, [2012-11-22T18:39:46.033483 #12800] DEBUG -- : [httplog] Benchmark: 0.001562 seconds
111
118
 
112
- * Also when using HTTPClient, make sure you include `httplog` **before** `httpclient` in your `Gemfile`.
119
+ * Also when using HTTPClient, make sure you include `httplog` **after** `httpclient` in your `Gemfile`.
113
120
 
114
121
  * When using Ethon or Patron, and any library based on them (such as Typhoeus),
115
122
  the TCP connection is not logged (since it's established by libcurl).
@@ -141,3 +148,4 @@ Thanks to these fine folks for contributing pull requests:
141
148
  * [Andrew Hammond](https://github.com/andrhamm)
142
149
  * [Chris Keele](https://github.com/christhekeele)
143
150
  * [Ryan Souza](https://github.com/ryansouza)
151
+ * [Ilya Bondarenko](https://github.com/sedx)
@@ -1,6 +1,7 @@
1
1
  require "net/http"
2
2
  require "logger"
3
3
  require "benchmark"
4
+ require "colorize"
4
5
 
5
6
  module HttpLog
6
7
  DEFAULT_LOGGER = Logger.new($stdout)
@@ -16,7 +17,8 @@ module HttpLog
16
17
  :log_benchmark => true,
17
18
  :compact_log => false,
18
19
  :url_whitelist_pattern => /.*/,
19
- :url_blacklist_pattern => nil
20
+ :url_blacklist_pattern => nil,
21
+ :color => false
20
22
  }
21
23
 
22
24
  LOG_PREFIX = "[httplog] ".freeze
@@ -44,7 +46,7 @@ module HttpLog
44
46
  # https://github.com/collectiveidea/delayed_job/commit/e7f5aa1ed806e61251bdb77daf25864eeb3aff59
45
47
  severities = Hash[*Logger::Severity.constants.enum_for(:each_with_index).collect{ |s, i| [i, s] }.flatten]
46
48
  severity = severities[options[:severity]].to_s.downcase
47
- options[:logger].send(severity, LOG_PREFIX + msg)
49
+ options[:logger].send(severity, colorize(LOG_PREFIX + msg))
48
50
  end
49
51
 
50
52
  def log_connection(host, port = nil)
@@ -93,7 +95,7 @@ module HttpLog
93
95
 
94
96
  def log_data(data)
95
97
  return if options[:compact_log] || !options[:log_data]
96
- data = CGI.unescape(data.to_s) if data
98
+ data = data.to_s.encode('UTF-8', :invalid => :replace, :undef => :replace) if data
97
99
  log("Data: #{data}")
98
100
  end
99
101
 
@@ -102,5 +104,10 @@ module HttpLog
102
104
  status = Rack::Utils.status_code(status) unless status == /\d{3}/
103
105
  log("#{method.to_s.upcase} #{uri} completed with status code #{status} in #{seconds} seconds")
104
106
  end
107
+
108
+ def colorize(msg)
109
+ return msg unless options[:color]
110
+ msg.send(:colorize, options[:color])
111
+ end
105
112
  end
106
113
  end
@@ -1,4 +1,4 @@
1
1
  module HttpLog
2
- VERSION = "0.2.13"
2
+ VERSION = "0.2.15"
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.2.13
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thilo Rusche
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-23 00:00:00.000000000 Z
11
+ date: 2015-12-06 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,42 +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
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: colorize
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - '>='
221
235
  - !ruby/object:Gem::Version
222
236
  version: '0'
223
237
  description: |-
@@ -228,10 +242,6 @@ executables: []
228
242
  extensions: []
229
243
  extra_rdoc_files: []
230
244
  files:
231
- - MIT-LICENSE
232
- - README.md
233
- - Rakefile
234
- - lib/httplog.rb
235
245
  - lib/httplog/adapters/ethon.rb
236
246
  - lib/httplog/adapters/excon.rb
237
247
  - lib/httplog/adapters/http.rb
@@ -240,6 +250,10 @@ files:
240
250
  - lib/httplog/adapters/patron.rb
241
251
  - lib/httplog/http_log.rb
242
252
  - lib/httplog/version.rb
253
+ - lib/httplog.rb
254
+ - MIT-LICENSE
255
+ - Rakefile
256
+ - README.md
243
257
  homepage: http://github.com/trusche/httplog
244
258
  licenses: []
245
259
  metadata: {}
@@ -249,17 +263,17 @@ require_paths:
249
263
  - lib
250
264
  required_ruby_version: !ruby/object:Gem::Requirement
251
265
  requirements:
252
- - - ">="
266
+ - - '>='
253
267
  - !ruby/object:Gem::Version
254
268
  version: '0'
255
269
  required_rubygems_version: !ruby/object:Gem::Requirement
256
270
  requirements:
257
- - - ">="
271
+ - - '>='
258
272
  - !ruby/object:Gem::Version
259
273
  version: '0'
260
274
  requirements: []
261
275
  rubyforge_project:
262
- rubygems_version: 2.2.3
276
+ rubygems_version: 2.0.14.1
263
277
  signing_key:
264
278
  specification_version: 4
265
279
  summary: Logs outgoing HTTP requests.