Class: Roqua::Support::RequestLogger

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Includes:
Instrumentation
Defined in:
lib/roqua/support/request_logger.rb

Instance Method Summary collapse

Methods included from Instrumentation

#eventlog, #with_instrumentation

Instance Method Details

#process_action(event) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/roqua/support/request_logger.rb', line 16

def process_action(event)
  payload = event.payload
  extra_logged_information = Thread.current[:roqua_request_log] || {}
  Thread.current[:roqua_request_log] = {}

  data      = extract_request_id(event)
  data.merge! extract_request(payload)
  data.merge! extract_status(payload)
  data.merge! extract_parameters(payload)
  data.merge! redirect_information
  data.merge! extra_logged_information
  data.merge! runtimes(event)

  #eventlog.info event.inspect
  eventlog.info "web", data
rescue Exception => e
  eventlog.info "web:logerror", {class: e.class, message: e.message}
  raise
end

#redirect_to(event) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/roqua/support/request_logger.rb', line 36

def redirect_to(event)
  # Unfortunately, when a redirect is triggered by your application's code,
  # ActionController fires two events. One for the redirect itself, and
  # another one when the request is finished. Unfortunately the final event
  # doesn't include the redirect, so we store the redirect URL as a
  # thread-local attribute and refers to it in process_action.
  Thread.current[:roqua_request_log_redirect] = event.payload[:location]
end