marcopolo 0.0.3 → 0.0.4

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: 3d7b9c6170d11433cef35c60dc59c7381d465796
4
- data.tar.gz: 79e60dc711051916638470ae3605c6d0a836acf5
3
+ metadata.gz: 023e1afa09c72d23e1e982318941a980e5ad841c
4
+ data.tar.gz: 725b1084a09540fd9996882f9acb324624853fd3
5
5
  SHA512:
6
- metadata.gz: 5181e779ffab1fd41bc20f93e3815351c05c79b97a8024a6f661b7aada28ee832a9732382a50ec12e42246ab9283641a0a6503ce29264ec2e1ab410cb3e9cc69
7
- data.tar.gz: 3dd424e72bfae1f83c6e6fa6746407becc7a56cba6d2cd57fa68847a3886a3720b2cfe02f2245d561c05a70897b074db3b0869112ad8536c782dae4ba3925923
6
+ metadata.gz: 2070d60fafe9cb7165d0ae92589ffed6f82210045aa34dfe4ddddb0b61de6377e45a6873fc48928514f3909aaa1e8c27475f9067612c7cadb0ad4af68cd43d5d
7
+ data.tar.gz: 572614652abe7cef657c9d13e56c79f3b92fe1832656bfe582926ceab36f994bca9dbf87ce3d7e33c084a55f43f5c275b1eb7683de7b2c21273e949456829291
data/README.md CHANGED
@@ -36,6 +36,7 @@ You may want to filter out noisy requests, such as health checks. Create a proc
36
36
 
37
37
  ## TODO
38
38
 
39
+ * Better log formatting!
39
40
  * Support for Sinatra?
40
41
  * Ability to disable for certain endpoints, etc
41
42
  * IP-based log segmenting?
@@ -15,11 +15,11 @@ module Marcopolo
15
15
  Marcopolo.log "Filtering request: #{@request.request_method} #{@request.url}"
16
16
  end
17
17
 
18
- @status, @headers, @response = @app.call(env)
18
+ status, headers, response = @app.call(env)
19
19
 
20
- rawlog_response(env) if allow
20
+ rawlog_response(status, headers, response) if allow
21
21
 
22
- return [@status, @headers, @response]
22
+ return [status, headers, response]
23
23
  end
24
24
 
25
25
  def rawlog_request(env)
@@ -38,28 +38,32 @@ module Marcopolo
38
38
  req_headers.to_a.each {|i| req_hash["\t" + i.first] = i.last }
39
39
 
40
40
  req_hash.merge!({
41
- "Request Body" => @request.body.gets
41
+ "Request Body" => @request.body.string
42
42
  })
43
43
 
44
44
  Marcopolo.log req_hash.to_a.map {|o| o.join(': ') }.join("\n") + "\n"
45
+ rescue => e
46
+ Marcopolo.log "Failed to log request: #{e}"
45
47
  end
46
48
 
47
- def rawlog_response(env)
49
+ def rawlog_response(status, headers, response)
48
50
  resp_hash = {
49
51
  "RESPONSE" => "",
50
- "Response Status" => @status,
52
+ "Response Status" => status,
51
53
  "Response Headers" => ""
52
54
  }
53
55
 
54
- @headers.to_a.each {|i| resp_hash["\t" + i.first] = i.last }
56
+ headers.to_a.each {|i| resp_hash["\t" + i.first] = i.last }
55
57
 
56
- response_body = @response.respond_to?(:body) ? @response.body : @response
58
+ response_body = response.respond_to?(:body) ? response.body : response
57
59
 
58
60
  resp_hash.merge!({
59
61
  "Response Body" => response_body
60
62
  })
61
63
 
62
64
  Marcopolo.log resp_hash.to_a.map {|o| o.join(': ') }.join("\n") + "\n"
65
+ rescue => e
66
+ Marcopolo.log "Failed to log response: #{e}"
63
67
  end
64
68
  end
65
69
  end
@@ -1,3 +1,3 @@
1
1
  module Marcopolo
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marcopolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hammond
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler