class ApiHammer::RequestLogSubscriber
Public Instance Methods
process_action(event)
click to toggle source
# File lib/api_hammer/rails_request_logging.rb, line 28 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'] # if there is an exception, ActiveSupport saves the class and message but not backtrace. but this # gets called from an ensure block, so $! is set - retrieve the backtrace from that. if $! # this may be paranoid - it should always be the case that what gets set in :exception is the # same as the current error, but just in case it's not, we'll put the current error somewhere else if info[:exception] == [$!.class.to_s, $!.message] info[:exception] += [$!.backtrace] else info[:current_exception] = [$!.class.to_s, $!.message, $!.backtrace] end end end