From 081431fdf180ec7395c769793b2270d244566ca2 Mon Sep 17 00:00:00 2001 From: Sergey Nartimov Date: Tue, 13 Dec 2011 22:32:39 +0300 Subject: log exception backtrace when all backtrace lines silenced --- .../lib/action_dispatch/middleware/debug_exceptions.rb | 5 ++++- actionpack/test/dispatch/debug_exceptions_test.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index 417701ea54..cd4af82c6e 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -59,10 +59,13 @@ module ActionDispatch exception = wrapper.exception + trace = wrapper.application_trace + trace = wrapper.framework_trace if trace.empty? + ActiveSupport::Deprecation.silence do message = "\n#{exception.class} (#{exception.message}):\n" message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code) - message << " " << wrapper.application_trace.join("\n ") + message << " " << trace.join("\n ") logger.fatal("#{message}\n\n") end end diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb index f7411c7729..6133bfe338 100644 --- a/actionpack/test/dispatch/debug_exceptions_test.rb +++ b/actionpack/test/dispatch/debug_exceptions_test.rb @@ -122,4 +122,17 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest get "/", {}, {'action_dispatch.show_exceptions' => true, 'action_dispatch.backtrace_cleaner' => cleaner} assert_match(/passed backtrace cleaner/, body) end + + test 'logs exception backtrace when all lines silenced' do + output = StringIO.new + backtrace_cleaner = ActiveSupport::BacktraceCleaner.new + backtrace_cleaner.add_silencer { true } + + env = {'action_dispatch.show_exceptions' => true, + 'action_dispatch.logger' => Logger.new(output), + 'action_dispatch.backtrace_cleaner' => backtrace_cleaner} + + get "/", {}, env + assert_operator (output.rewind && output.read).lines.count, :>, 10 + end end -- cgit v1.2.3