Sha256: 913979ee4e11118fb95d78f248786f93813f2394f572312b4c935ae67f19cbe0
Contents?: true
Size: 1.13 KB
Versions: 18
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require "active_support/backtrace_cleaner" require "active_support/core_ext/string/access" module Rails class BacktraceCleaner < ActiveSupport::BacktraceCleaner # :nodoc: APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/ RENDER_TEMPLATE_PATTERN = /:in [`'].*_\w+_{2,3}\d+_\d+'/ def initialize super add_filter do |line| # We may be called before Rails.root is assigned. # When that happens we fallback to not truncating. @root ||= Rails.root && "#{Rails.root}/" @root && line.start_with?(@root) ? line.from(@root.size) : line end add_filter do |line| if RENDER_TEMPLATE_PATTERN.match?(line) line.sub(RENDER_TEMPLATE_PATTERN, "") else line end end add_silencer { |line| !APP_DIRS_PATTERN.match?(line) } end def clean(backtrace, kind = :silent) kind = nil if ENV["BACKTRACE"] super(backtrace, kind) end alias_method :filter, :clean def clean_frame(frame, kind = :silent) kind = nil if ENV["BACKTRACE"] super(frame, kind) end end end
Version data entries
18 entries across 18 versions & 2 rubygems