Sha256: e97e926ba09dbca218c1d265c523611e7af41a81cb524bb177858941a90116dc
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
module Erorr class Notification def initialize(exception, params = {}) @exception = exception @params = params end def to_params { class: @exception.class.name, message: @exception.message, location: location, backtrace: backtrace.join("\n"), environment: Erorr.config.env, timestamp: Time.current, fingerprint: fingerprint, host: Socket.gethostname, pid: Process.pid, request_params: @params.dig(:request, :params), request_remote_ip: @params.dig(:request, :remote_ip), } end private def location @params[:location] || $PROGRAM_NAME end def backtrace @_backtrace ||= begin cleaner = ActiveSupport::BacktraceCleaner.new gem_paths.each { |gem_path| cleaner.add_filter { |line| line.sub(gem_path, '') } } cleaner.add_filter { |line| line.sub(Erorr.config.root.to_s, '') } cleaner.add_filter { |line| line.sub('/', '') } cleaner.clean(@exception.backtrace) end end def fingerprint first_backtrace_line = backtrace.find { |trace| trace !~ /pry|irb/ } checksum = [first_backtrace_line, @exception.class].join('|') Digest::SHA1.hexdigest checksum end def gem_paths @gem_paths ||= Gem.path | [Gem.default_dir] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
erorr-0.1.1 | lib/erorr/notification.rb |
erorr-0.1.0 | lib/erorr/notification.rb |