simple-rack-logger 0.0.2 → 0.0.3
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.
@@ -19,10 +19,9 @@ module Rack
|
|
19
19
|
|
20
20
|
def call(env)
|
21
21
|
request = Rack::Request.new(env)
|
22
|
-
block
|
23
|
-
|
22
|
+
block = @filters.select { |filter| filter.respond_to?(:filter) && filter.send(:filter, request) }
|
24
23
|
if block.empty?
|
25
|
-
logger.info(expose(request))
|
24
|
+
logger.info(expose(request, env))
|
26
25
|
logger.flush
|
27
26
|
end
|
28
27
|
|
@@ -30,9 +29,16 @@ module Rack
|
|
30
29
|
end
|
31
30
|
|
32
31
|
private
|
33
|
-
def expose(request)
|
32
|
+
def expose(request, env)
|
33
|
+
show = "#{request.request_method}: #{request.url} for #{request.ip}"
|
34
|
+
|
34
35
|
params = request.params.map { |key, value| "#{key}=#{value}" }
|
35
|
-
|
36
|
+
show << "[params: #{params.join('; ')}]" unless params.empty?
|
37
|
+
|
38
|
+
headers = env.select { |key, value| key.start_with?('HTTP_') }
|
39
|
+
show << " [heades: #{headers.collect { |pair| pair.join("=") }}" unless headers.empty?
|
40
|
+
|
41
|
+
show
|
36
42
|
end
|
37
43
|
|
38
44
|
end
|
@@ -42,7 +42,7 @@ describe Rack::RequestLogger do
|
|
42
42
|
|
43
43
|
it 'log request information from env' do
|
44
44
|
app.should_receive(:call)
|
45
|
-
logger.should_receive(:info).with('GET: http://localhost:9393/v1/crachas.xml for 127.0.0.1
|
45
|
+
logger.should_receive(:info).with('GET: http://localhost:9393/v1/crachas.xml for 127.0.0.1 [heades: ["HTTP_USER_AGENT=curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3", "HTTP_HOST=localhost:9393", "HTTP_ACCEPT=*/*", "HTTP_VERSION=HTTP/1.1"]')
|
46
46
|
subject.call(env)
|
47
47
|
end
|
48
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-rack-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple rack for log information from environment.
|
15
15
|
email:
|