diff options
author | Lachlan Sylvester <lachlan.sylvester@publicisfrontfoot.com.au> | 2018-08-06 11:06:01 +1000 |
---|---|---|
committer | Lachlan Sylvester <lachlan.sylvester@publicisfrontfoot.com.au> | 2018-08-14 09:15:28 +1000 |
commit | c675783eb4fb42a357ec068d4cfd83bf08f78aea (patch) | |
tree | 3b33266cddd9656569ab5f998980c64255e0f01c /railties | |
parent | ffc4703f22888dce0394fe0ab524a9e6cdc3c7e5 (diff) | |
download | rails-c675783eb4fb42a357ec068d4cfd83bf08f78aea.tar.gz rails-c675783eb4fb42a357ec068d4cfd83bf08f78aea.tar.bz2 rails-c675783eb4fb42a357ec068d4cfd83bf08f78aea.zip |
Use backtrace cleaner to clean up backtrace for verbose query logs
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/backtrace_cleaner.rb | 12 | ||||
-rw-r--r-- | railties/test/backtrace_cleaner_test.rb | 16 |
2 files changed, 0 insertions, 28 deletions
diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb index 0e78959966..b1e3c923b7 100644 --- a/railties/lib/rails/backtrace_cleaner.rb +++ b/railties/lib/rails/backtrace_cleaner.rb @@ -16,19 +16,7 @@ module Rails add_filter { |line| line.sub(@root, EMPTY_STRING) } add_filter { |line| line.sub(RENDER_TEMPLATE_PATTERN, EMPTY_STRING) } add_filter { |line| line.sub(DOT_SLASH, SLASH) } # for tests - - add_gem_filters add_silencer { |line| !APP_DIRS_PATTERN.match?(line) } end - - private - def add_gem_filters - gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) } - return if gems_paths.empty? - - gems_regexp = %r{(#{gems_paths.join('|')})/gems/([^/]+)-([\w.]+)/(.*)} - gems_result = '\2 (\3) \4'.freeze - add_filter { |line| line.sub(gems_regexp, gems_result) } - end end end diff --git a/railties/test/backtrace_cleaner_test.rb b/railties/test/backtrace_cleaner_test.rb index 8490f9eb10..90e084ddca 100644 --- a/railties/test/backtrace_cleaner_test.rb +++ b/railties/test/backtrace_cleaner_test.rb @@ -8,22 +8,6 @@ class BacktraceCleanerTest < ActiveSupport::TestCase @cleaner = Rails::BacktraceCleaner.new end - test "should format installed gems correctly" do - backtrace = [ "#{Gem.path[0]}/gems/nosuchgem-1.2.3/lib/foo.rb" ] - result = @cleaner.clean(backtrace, :all) - assert_equal "nosuchgem (1.2.3) lib/foo.rb", result[0] - end - - test "should format installed gems not in Gem.default_dir correctly" do - target_dir = Gem.path.detect { |p| p != Gem.default_dir } - # skip this test if default_dir is the only directory on Gem.path - if target_dir - backtrace = [ "#{target_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ] - result = @cleaner.clean(backtrace, :all) - assert_equal "nosuchgem (1.2.3) lib/foo.rb", result[0] - end - end - test "should consider traces from irb lines as User code" do backtrace = [ "(irb):1", "/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'", |