Class: RequestLog::Data
- Inherits:
-
Object
- Object
- RequestLog::Data
- Defined in:
- lib/request_log/data.rb
Instance Attribute Summary collapse
-
#app_time ⇒ Object
Returns the value of attribute app_time.
-
#env ⇒ Object
Returns the value of attribute env.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#response ⇒ Object
Returns the value of attribute response.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(env, rack_response, app_time) ⇒ Data
constructor
A new instance of Data.
- #params ⇒ Object
Constructor Details
#initialize(env, rack_response, app_time) ⇒ Data
Returns a new instance of Data.
5 6 7 8 9 10 11 |
# File 'lib/request_log/data.rb', line 5 def initialize(env, rack_response, app_time) self.env = env self.status = rack_response[0] self.headers = rack_response[1] self.response = rack_response[2] self.app_time = app_time end |
Instance Attribute Details
#app_time ⇒ Object
Returns the value of attribute app_time.
3 4 5 |
# File 'lib/request_log/data.rb', line 3 def app_time @app_time end |
#env ⇒ Object
Returns the value of attribute env.
3 4 5 |
# File 'lib/request_log/data.rb', line 3 def env @env end |
#headers ⇒ Object
Returns the value of attribute headers.
3 4 5 |
# File 'lib/request_log/data.rb', line 3 def headers @headers end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/request_log/data.rb', line 3 def response @response end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/request_log/data.rb', line 3 def status @status end |
Class Method Details
.request_path(env) ⇒ Object
13 14 15 |
# File 'lib/request_log/data.rb', line 13 def self.request_path(env) env['PATH_INFO'] || env['REQUEST_PATH'] || "/" end |
Instance Method Details
#attributes ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/request_log/data.rb', line 17 def attributes method = env['REQUEST_METHOD'] path = self.class.request_path(env) { :method => method, :path => path, :status => status, :time => Time.now.utc, :runtime => app_time, :ip => env['REMOTE_ADDR'], :params => params } end |
#params ⇒ Object
31 32 33 34 |
# File 'lib/request_log/data.rb', line 31 def params # NOTE: It seems getting POST params with ::Rack::Request.new(env).params does not work well with Rails (env['action_controller.instance'] || ::Rack::Request.new(env)).params end |