rack-detailed_request_logger 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,10 @@ rack-detailed_request_logger
2
2
  ============================
3
3
  * Logs requests to your RACK app's recording the raw POST, PUT data etc
4
4
 
5
+ Install
6
+ -------
7
+ gem install rack-detailed_request_logger
8
+
5
9
  Usage
6
10
  -----
7
11
  require "rack/detailed_request_logger"
@@ -11,5 +15,6 @@ Usage
11
15
 
12
16
  Sample Output
13
17
  -------------
14
- I, [2010-10-07T10:59:58.072869 #1523] INFO -- : From IP: 127.0.0.1, To: POST /docs, Raw POST Data: YOYO=KK
15
- I, [2010-10-07T11:00:01.853890 #1523] INFO -- : From IP: 127.0.0.1, To: GET /docs, Raw POST Data:
18
+ I, [2010-10-07T10:59:58.072869 #1523] INFO -- : From IP: 127.0.0.1, To: POST /docs, Raw POST Data: YOYO=KK
19
+ I, [2010-10-07T11:00:01.853890 #1523] INFO -- : From IP: 127.0.0.1, To: GET /docs, Raw POST Data:
20
+ I, [2010-10-07T11:02:19.103929 #1523] INFO -- : From IP: 127.0.0.1, To: PUT /docs, Raw POST Data: name=Matt
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -6,12 +6,19 @@ module Rack
6
6
  end
7
7
 
8
8
  def call(env)
9
+ # generate log data
10
+ post_data = env["rack.input"].gets
9
11
  to = "To: #{env["REQUEST_METHOD"]} #{env["PATH_INFO"]}"
10
12
  to << "?#{env["QUERY_STRING"]}" unless env["QUERY_STRING"].nil? || env["QUERY_STRING"].blank?
11
13
  entry = ["From IP: #{env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-"}"]
12
14
  entry << to
13
- entry << "Raw POST Data: #{env["rack.input"].gets}"
15
+ entry << "Raw POST Data: #{post_data}"
14
16
  @logger.info entry.join(", ")
17
+
18
+ # restore the value of env["rack.input"]
19
+ env["rack.input"] = StringIO.new(post_data) if post_data
20
+
21
+ # return the app
15
22
  status, header, body = @app.call(env)
16
23
  [status, header, body]
17
24
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-detailed_request_logger}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Fawcett"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-detailed_request_logger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Fawcett