class DraftLog::LogSubscriber
Public Instance Methods
process_action(event)
click to toggle source
# File lib/draft_log/log_subscriber.rb, line 6 def process_action(event) payload = event.payload param_method = payload[:params]["_method"] method = param_method ? param_method.upcase : payload[:method] message = %Q{\nWe received a request at #{Time.now.strftime("%I:%M%p on %A, %b %d!")} Someone wants to #{method} #{payload[:path]} The route told me to use the #{payload[:controller].ai} and #{payload[:action].ai} action.\n\n} message += flexible_path_segment(payload) if payload[:path_param].present? message += custom_query_string(payload) if payload[:query_string].present? message += custom_params(payload) if payload[:params].present? # message += custom_cookies(payload) if payload[:cookies].present? # message += custom_session(payload) if payload[:session].present? message += custom_instance_var(payload) if payload[:controller_instance_var].present? message += view_log(payload) if payload[:view_log_event_data].present? message += "==============================================================================================================\n" logger.warn message end
Private Instance Methods
custom_instance_var(payload)
click to toggle source
# File lib/draft_log/log_subscriber.rb, line 57 def custom_instance_var(payload) %Q{The "#{payload[:controller].ai}##{payload[:action].ai}" action defined these instance variables: #{payload[:controller_instance_var].ai}\n\n} end
custom_params(payload)
click to toggle source
# File lib/draft_log/log_subscriber.rb, line 40 def custom_params(payload) "The final params hash containing all inputs looks like this: # params #{payload[:params].ai}\n\n" end
custom_query_string(payload)
click to toggle source
# File lib/draft_log/log_subscriber.rb, line 35 def custom_query_string(payload) "I found these inputs in the query string: #{payload[:query_string].ai}\n\n" end
custom_session(payload)
click to toggle source
# File lib/draft_log/log_subscriber.rb, line 52 def custom_session(payload) " # session #{payload[:session].ai}\n\n" end
flexible_path_segment(payload)
click to toggle source
# File lib/draft_log/log_subscriber.rb, line 30 def flexible_path_segment(payload) "I found these inputs in flexible path segments: #{payload[:path_param].ai}\n\n" end
view_log(payload)
click to toggle source
# File lib/draft_log/log_subscriber.rb, line 62 def view_log(payload) template_path = payload[:view_log_event_data][:identifier].sub("#{Rails.root.to_s}/", '') %Q{The #{(payload[:controller] + "#" + payload[:action]).ai} action told me to use #{template_path.ai} to format the response.\n\n} end