Sha256: f42fe83cd6f15d10bc191b7078c724fd2b286ed1a1b67a3d322c78a65f3a1d59
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 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), request_headers: @params.dig(:request, :headers), } 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
erorr-0.2.2 | lib/erorr/notification.rb |
erorr-0.2.1 | lib/erorr/notification.rb |
erorr-0.2.0 | lib/erorr/notification.rb |
erorr-0.1.2 | lib/erorr/notification.rb |