Class: Stasher::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Stasher::LogSubscriber
- Defined in:
- lib/stasher/log_subscriber.rb
Instance Method Summary collapse
- #process_action(ev) ⇒ Object
- #redirect_to(ev) ⇒ Object
- #sql(ev) ⇒ Object
- #start_processing(ev) ⇒ Object
Instance Method Details
#process_action(ev) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stasher/log_subscriber.rb', line 16 def process_action(ev) payload = ev.payload data = extract_request(payload) data.merge! extract_status(payload) data.merge! runtimes(ev) data.merge! extract_exception(payload) data.merge! extract_current_scope log_event 'response', data do |event| event. << 'exception' if payload[:exception] end # Clear the scope at the end of the request Stasher::CurrentScope.clear! end |
#redirect_to(ev) ⇒ Object
47 48 49 |
# File 'lib/stasher/log_subscriber.rb', line 47 def redirect_to(ev) Stasher::CurrentScope.fields[:location] = ev.payload[:location] end |
#sql(ev) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/stasher/log_subscriber.rb', line 33 def sql(ev) payload = ev.payload return if 'SCHEMA' == payload[:name] return if payload[:name].blank? return if payload[:name] =~ /ActiveRecord::SessionStore/ data = extract_sql(payload) data.merge! runtimes(ev) data.merge! extract_current_scope log_event 'sql', data end |
#start_processing(ev) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/stasher/log_subscriber.rb', line 6 def start_processing(ev) # Initialize the scope at the start of the request payload = ev.payload data = extract_request(payload) data.merge! extract_current_scope log_event 'request', data end |