Class: WhoopsRailsLogger::ExceptionStrategy
- Inherits:
-
WhoopsLogger::Strategy
- Object
- WhoopsLogger::Strategy
- WhoopsRailsLogger::ExceptionStrategy
- Defined in:
- lib/whoops_rails_logger/exception_strategy.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#service ⇒ Object
Returns the value of attribute service.
Instance Method Summary collapse
- #add_message_builders ⇒ Object
-
#initialize(strategy_name) ⇒ ExceptionStrategy
constructor
A new instance of ExceptionStrategy.
Constructor Details
#initialize(strategy_name) ⇒ ExceptionStrategy
Returns a new instance of ExceptionStrategy.
6 7 8 9 10 11 12 13 |
# File 'lib/whoops_rails_logger/exception_strategy.rb', line 6 def initialize(strategy_name) super self.service = ::Rails.application.class.name.split("::").first.downcase + ".web" self.environment = ::Rails.env end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
5 6 7 |
# File 'lib/whoops_rails_logger/exception_strategy.rb', line 5 def environment @environment end |
#service ⇒ Object
Returns the value of attribute service.
5 6 7 |
# File 'lib/whoops_rails_logger/exception_strategy.rb', line 5 def service @service end |
Instance Method Details
#add_message_builders ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/whoops_rails_logger/exception_strategy.rb', line 15 def self.(:basic_details) do |, raw_data| .service = self.service .environment = self.environment .event_type = "exception" . = raw_data[:exception]. .event_time = Time.now end self.(:details) do |, raw_data| exception = raw_data[:exception] rack_env = raw_data[:rack_env] rack_req = ::Rack::Request.new(rack_env) details = {} details[:backtrace] = exception.backtrace.collect{ |line| line.sub(/^#{ENV['GEM_HOME']}/, '$GEM_HOME').sub(/^#{Rails.root}/, '$Rails.root') } details[:http_host] = rack_env["HTTP_HOST"] details[:params] = rack_env["action_dispatch.request.parameters"] details[:raw_post_data] = rack_env["RAW_POST_DATA"] details[:controller] = details[:params][:controller] if details[:params] details[:action] = details[:params][:action] if details[:params] details[:query_string] = rack_env["QUERY_STRING"] details[:remote_addr] = rack_env["REMOTE_ADDR"] details[:request_method] = rack_env["REQUEST_METHOD"] details[:server_name] = rack_env["SERVER_NAME"] details[:session] = rack_env["rack.session"] details[:env] = ENV.to_hash details[:url] = rack_req.url .details = details end self.(:create_event_group_identifier) do |, raw_data| identifier = "#{.details[:controller]}##{.details[:action]}" identifier << .details[:backtrace].collect{|b| b.gsub(/:in.*/, "")}.join("\n") .event_group_identifier = Digest::MD5.hexdigest(identifier) end end |