Sha256: 9aae933b26e03116768c9e9d6723b2c892e6e3eb567778244e332650fd9975f5
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
module Chatterbox::ExceptionNotification class RailsExtracter def self.wrap(notification = {}) new(notification).notice end def initialize(message = {}) @message = message end def notice hsh = extract_rails_info(@message) hsh = extract_request_info(hsh) hsh = filter_rails_root(hsh) hsh end def filter_rails_root(hsh) return hsh unless hsh[:backtrace] cleaner = ActiveSupport::BacktraceCleaner.new cleaner.add_filter { |line| line.gsub(rails_root, "[RAILS_ROOT]") } backtrace = cleaner.clean(hsh[:backtrace]) hsh[:backtrace] = backtrace hsh end def extract_rails_info(message) return message if rails_configuration.nil? message.merge({ :rails_info => { :rails_env => rails_configuration.env.to_s, :rails_root => rails_root, :rails_version => rails_configuration.version } }) end def extract_request_info(message) return message unless message.key?(:request) request = message.delete(:request) message.merge({ :request => { :url => request.url, :remote_ip => request.remote_ip, :parameters => request.parameters } }) end def rails_root rails_configuration.try(:root).to_s end def rails_configuration Object.const_get("Rails") if Object.const_defined?("Rails") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chatterbox-0.5.4 | lib/chatterbox/exception_notification/rails_extracter.rb |
chatterbox-0.5.3 | lib/chatterbox/exception_notification/rails_extracter.rb |