Class: CustomRequestLogger::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- CustomRequestLogger::LogSubscriber
- Defined in:
- lib/pineapples/templates/lib/logging/custom_request_logger.rb
Constant Summary collapse
- INTERNAL_PARAMS =
%w(controller action format _method only_path)
Instance Method Summary collapse
Instance Method Details
#process_action(event) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pineapples/templates/lib/logging/custom_request_logger.rb', line 17 def process_action(event) indent = 8 payload = event.payload param_method = payload[:params]['_method'] status = compute_status(payload) path = payload[:path] params = payload[:params].except(*INTERNAL_PARAMS) redirect_to = Thread.current[:redirect_to] Thread.current[:redirect_to] = nil = "Status: #{status} for \"#{path}\" \n" << "Redirect URL: #{redirect_to} \n" if redirect_to << "Params: #{format_data(params, indent)} \n" if params.present? info() end |
#redirect_to(event) ⇒ Object
35 36 37 |
# File 'lib/pineapples/templates/lib/logging/custom_request_logger.rb', line 35 def redirect_to(event) Thread.current[:redirect_to] = event.payload[:location] end |
#start_processing(event) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/pineapples/templates/lib/logging/custom_request_logger.rb', line 7 def start_processing(event) payload = event.payload params = payload[:params].except(*INTERNAL_PARAMS) format = payload[:format] format = format.to_s.upcase if format.is_a?(Symbol) info "Action: #{payload[:controller]}##{payload[:action]} \nFormat: #{format}" #logger.info "Parameters: #{params.inspect}" unless params.empty? end |