Class: ApiHammer::RequestLogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/api_hammer/rails_request_logging.rb

Instance Method Summary collapse

Instance Method Details

#process_action(event) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/api_hammer/rails_request_logging.rb', line 20

def process_action(event)
  if event.payload[:request_env]
    info = (event.payload[:request_env]['request_logger.info'] ||= {})
  else
    # if an exception occurs in the action, append_info_to_payload isn't called and 
    # event.payload[:request_env] doesn't get set. fall back to use Thread.current.
    info = (Thread.current['request_logger.info'] ||= {})
  end
  info.update(event.payload.slice(:controller, :action, :exception, :format, :formats, :view_runtime, :db_runtime))
  info.update(:transaction_id => event.transaction_id)
  info.update(event.payload['request_logger.info']) if event.payload['request_logger.info']
end