rack-action_logger 0.1.3 → 0.1.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b67195a74ca4d8eba2de552e0867fd5eeac22e8
|
4
|
+
data.tar.gz: bd5f047381c02cda831427f807e9e2d35a162ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7489f225eef57d0860dc614f94fd8885d793fc6c5d3fd3f87ce2b6e284010c939959677a9373b9d8909f57d7eff2f8f00c12948698684447efd670e7086d0a14
|
7
|
+
data.tar.gz: b28e66ac460fac009832730844751aa6dbc7a358d51f0d3718317e40c5b5eee4ad0d6c3dc541843e3a94a0f81f1a424ebf3aef582e4ff87cf54cd7238642becf
|
data/Gemfile.lock
CHANGED
@@ -15,6 +15,7 @@ module Rack::ActionLogger
|
|
15
15
|
attr_accessor :rack_request_blacklist
|
16
16
|
attr_accessor :pretty_print
|
17
17
|
attr_accessor :rack_metrics
|
18
|
+
attr_accessor :rack_content_types
|
18
19
|
|
19
20
|
def initialize
|
20
21
|
@emit_adapter = EmitAdapter::LoggerAdapter
|
@@ -25,6 +26,7 @@ module Rack::ActionLogger
|
|
25
26
|
@rack_request_blacklist = [:request_headers, :response_headers, :response_json_body]
|
26
27
|
@pretty_print = true
|
27
28
|
@rack_metrics = Rack::ActionLogger::Metrics::RackMetrics
|
29
|
+
@rack_content_types = %w(text/html application/json)
|
28
30
|
end
|
29
31
|
|
30
32
|
def tag_prefix
|
@@ -19,6 +19,7 @@ module Rack::ActionLogger::Metrics
|
|
19
19
|
@headers = headers
|
20
20
|
@body = body
|
21
21
|
@request = Rack::Request.new(env)
|
22
|
+
@response = Rack::Response.new(body, status_code, headers)
|
22
23
|
@ua = Woothee.parse(@request.user_agent)
|
23
24
|
filters = Rack::ActionLogger.configuration.filters
|
24
25
|
@compiled_filters = Rack::ActionLogger::ParameterFiltering.compile(filters)
|
@@ -34,7 +35,7 @@ module Rack::ActionLogger::Metrics
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def metrics
|
37
|
-
return unless
|
38
|
+
return unless enable_metrics
|
38
39
|
METRICS.inject({}) do |result, metric|
|
39
40
|
result[metric] = self.send(metric) unless
|
40
41
|
Rack::ActionLogger.configuration.rack_request_blacklist.include? metric
|
@@ -58,10 +59,18 @@ module Rack::ActionLogger::Metrics
|
|
58
59
|
@env.select { |v| v.start_with? 'HTTP_' }
|
59
60
|
end
|
60
61
|
|
62
|
+
def enable_metrics
|
63
|
+
Rack::ActionLogger.configuration.rack_content_types.any? { |c| content_type.include?(c) } || action_controller
|
64
|
+
end
|
65
|
+
|
61
66
|
def action_controller
|
62
67
|
@env['action_controller.instance']
|
63
68
|
end
|
64
69
|
|
70
|
+
def content_type
|
71
|
+
@response.content_type
|
72
|
+
end
|
73
|
+
|
65
74
|
def remote_ip
|
66
75
|
@request.ip
|
67
76
|
end
|