mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ensure show exceptions middleware properly filters backtrace before logging.
This commit is contained in:
parent
fa15111d30
commit
211799450d
2 changed files with 21 additions and 1 deletions
|
@ -135,7 +135,7 @@ module ActionDispatch
|
||||||
ActiveSupport::Deprecation.silence do
|
ActiveSupport::Deprecation.silence do
|
||||||
message = "\n#{exception.class} (#{exception.message}):\n"
|
message = "\n#{exception.class} (#{exception.message}):\n"
|
||||||
message << exception.annoted_source_code if exception.respond_to?(:annoted_source_code)
|
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")
|
logger.fatal("#{message}\n\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'isolation/abstract_unit'
|
require 'isolation/abstract_unit'
|
||||||
|
require 'stringio'
|
||||||
|
|
||||||
module ApplicationTests
|
module ApplicationTests
|
||||||
class MiddlewareTest < Test::Unit::TestCase
|
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")
|
assert_equal "1.1.1.1", remote_ip("REMOTE_ADDR" => "4.2.42.42,1.1.1.1")
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def boot!
|
def boot!
|
||||||
|
|
Loading…
Reference in a new issue