httplog 0.3.0 → 0.3.1

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: cf4cc23f31ff23be6b482a93162f13f24f3a1ff0
4
- data.tar.gz: 3f649844b6d24e7352d834f24391fff4803270a9
3
+ metadata.gz: 34ea5d5a3d79f010bc367c72fb3296c489907adf
4
+ data.tar.gz: e5972f20db489dd25c0d4949a9f1ea10921112f5
5
5
  SHA512:
6
- metadata.gz: dc9258c783313ef2293e9681d5cca9bc069cd3f9010bf9c03425e2828d8e8b39e771a5af10d3323598a7dcf84f52dad0f1b662256b55d786124198da250253f2
7
- data.tar.gz: a8e8e2d9e43241ae5cf017954222ec5ac4dbf5c55a61f76085fcecdb61fd572b365f7464d86f7754f19182a49eef4950ea9d569d0e2499848f7c37f89648bf75
6
+ metadata.gz: ae5751a11e8628998d96f3ea5327f1611ce80ec740de63006995cdcc9c79ded044bc8db717f8d51679a6dfbdfaf3c96fe9c335d55fa35ea472735a9c27928abb
7
+ data.tar.gz: 0b81643d6f33074cbb5b8e4041310f77c7e349e037d8167e1c3ae77f0a935c33924ca9c163ec8bba18f7637c70ff66cc3f462de2c5011b8a13d96e7b502d786c
data/README.md CHANGED
@@ -15,7 +15,7 @@ So far this gem works with the following ruby modules and libraries:
15
15
  * [Patron](https://github.com/toland/patron)
16
16
  * [HTTPClient](https://github.com/nahi/httpclient)
17
17
  * [HTTParty](https://github.com/jnunemaker/httparty)
18
- * [HTTP](https://github.com/httprb/http) (**Up to version 0.8.14**; see known issues below)
18
+ * [HTTP](https://github.com/httprb/http)
19
19
 
20
20
  These libraries are at least partially supported, where they use one of the above as adapters:
21
21
 
@@ -34,7 +34,7 @@ use this in a production environment.
34
34
 
35
35
  ### Usage
36
36
 
37
- require 'httplog'
37
+ require 'httplog' # require this *after* your HTTP gem of choice
38
38
 
39
39
  By default, this will log all outgoing HTTP requests and their responses to $stdout on DEBUG level.
40
40
 
@@ -75,6 +75,10 @@ You can colorize the output to make it stand out in your logfile:
75
75
 
76
76
  For more color options see [colorize documentation](https://github.com/fazibear/colorize/blob/master/README.md)
77
77
 
78
+ ### Compact logging
79
+
80
+ If the log is too noisy for you, but you don't want to completely disable it either, set the `compact_log` option to `true`. This will log each request in a single line with method, request URI, response status and time, but no data or headers. No need to disable any other options individually.
81
+
78
82
  ### Example
79
83
 
80
84
  With the default configuration, the log output might look like this:
@@ -93,10 +97,11 @@ With the default configuration, the log output might look like this:
93
97
  </body>
94
98
  </html>
95
99
 
100
+ With `compact_log` enabled, the same request might look like this:
96
101
 
97
- ### Known Issues
102
+ [httplog] GET http://localhost:9292/index.html completed with status code 200 in 0.00057 seconds
98
103
 
99
- * The [httprb/http](https://github.com/httprb/http) gem made some breaking changes in v0.9.0 that I haven't had time to fix yet. Pull requests welcome, but they should be backwards compatible to <= 0.8.14.
104
+ ### Known Issues
100
105
 
101
106
  * Requests types other than GET and POST have not been explicitly tested.
102
107
  They may or may not be logged, depending on the implementation details of the underlying library.
@@ -1,9 +1,13 @@
1
- if defined?(::HTTP::Client) and defined?(::HTTP::Connection)
1
+ if defined?(::HTTP::Client) && defined?(::HTTP::Connection)
2
2
  module ::HTTP
3
3
  class Client
4
- alias_method(:orig_make_request, :make_request) unless method_defined?(:orig_make_request)
5
4
 
6
- def make_request(req, options)
5
+ #
6
+ request_method = respond_to?('make_request') ? 'make_request' : 'perform'
7
+ orig_request_method = "orig_#{request_method}"
8
+ alias_method(orig_request_method, request_method) unless method_defined?(orig_request_method)
9
+
10
+ define_method request_method do |req, options|
7
11
 
8
12
  log_enabled = HttpLog.url_approved?(req.uri)
9
13
 
@@ -14,7 +18,7 @@ if defined?(::HTTP::Client) and defined?(::HTTP::Connection)
14
18
  end
15
19
 
16
20
  bm = Benchmark.realtime do
17
- @response = orig_make_request(req, options)
21
+ @response = send(orig_request_method, req, options)
18
22
  end
19
23
 
20
24
  if log_enabled
@@ -28,16 +32,13 @@ if defined?(::HTTP::Client) and defined?(::HTTP::Connection)
28
32
 
29
33
  @response
30
34
  end
31
-
32
35
  end
33
36
 
34
37
  class Connection
35
38
  alias_method(:orig_initialize, :initialize) unless method_defined?(:orig_initialize)
36
39
 
37
40
  def initialize(req, options)
38
-
39
41
  HttpLog.log_connection(req.uri.host, req.uri.port) if HttpLog.url_approved?(req.uri)
40
-
41
42
  orig_initialize(req, options)
42
43
  end
43
44
  end
@@ -1,4 +1,4 @@
1
1
  module HttpLog
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httplog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
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-01-15 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 0.8.14
173
+ version: 1.0.4
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 0.8.14
180
+ version: 1.0.4
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: simplecov
183
183
  requirement: !ruby/object:Gem::Requirement