aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-06-09 22:48:50 +0200
committerJosé Valim <jose.valim@gmail.com>2010-06-09 22:49:14 +0200
commit211799450d25c3e6a42a48a5146af5bed78cd66d (patch)
tree282531aade31095f24232771bfabd871d1c9f20d
parentfa15111d30f05edac7e4f63264e25887a5a4ae20 (diff)
downloadrails-211799450d25c3e6a42a48a5146af5bed78cd66d.tar.gz
rails-211799450d25c3e6a42a48a5146af5bed78cd66d.tar.bz2
rails-211799450d25c3e6a42a48a5146af5bed78cd66d.zip
Ensure show exceptions middleware properly filters backtrace before logging.
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb2
-rw-r--r--railties/test/application/middleware_test.rb20
2 files changed, 21 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index 8a2d8cd077..0a6d2bfc8a 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -135,7 +135,7 @@ module ActionDispatch
ActiveSupport::Deprecation.silence do
message = "\n#{exception.class} (#{exception.message}):\n"
message << exception.annoted_source_code if exception.respond_to?(:annoted_source_code)
- message << exception.backtrace.join("\n ")
+ message << " " << application_trace(exception).join("\n ")
logger.fatal("#{message}\n\n")
end
end
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb
index aa75fed793..999f666a64 100644
--- a/railties/test/application/middleware_test.rb
+++ b/railties/test/application/middleware_test.rb
@@ -1,4 +1,5 @@
require 'isolation/abstract_unit'
+require 'stringio'
module ApplicationTests
class MiddlewareTest < Test::Unit::TestCase
@@ -163,6 +164,25 @@ module ApplicationTests
assert_equal "1.1.1.1", remote_ip("REMOTE_ADDR" => "4.2.42.42,1.1.1.1")
end
+ test "show exceptions middleware filter backtrace before logging" do
+ my_middleware = Struct.new(:app) do
+ def call(env)
+ raise "Failure"
+ end
+ end
+
+ make_basic_app do |app|
+ app.config.middleware.use my_middleware
+ end
+
+ stringio = StringIO.new
+ Rails.logger = Logger.new(stringio)
+
+ env = Rack::MockRequest.env_for("/")
+ Rails.application.call(env)
+ assert_no_match(/action_dispatch/, stringio.string)
+ end
+
private
def boot!