Class: CustomActionControllerLogSubscriber

Inherits:
ActionController::LogSubscriber
  • Object
show all
Defined in:
lib/hot_catch/custom_log_subscribers.rb

Instance Method Summary collapse

Instance Method Details

#process_action(event) ⇒ Object

Статус записывается в лог файл hot_catch_buf_file



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/hot_catch/custom_log_subscribers.rb', line 43

def process_action(event)
  payload   = event.payload
  additions = ActionController::Base.log_process_action(payload)

  status = payload[:status]
  if status.nil? && payload[:exception].present?
    exception_class_name = payload[:exception].first
    status = ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class_name)
  end

  File.open('tmp/hot_catch_buf_file', 'a'){ |file| file.puts "!!!#{status}!!!" }

  info do

    message = "Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in #{event.duration.round}ms"
    message << " (#{additions.join(" | ")})" unless additions.blank?
    message
  end
end