提交 21179945 编写于 作者: J José Valim

Ensure show exceptions middleware properly filters backtrace before logging.

上级 fa15111d
......@@ -135,7 +135,7 @@ def log_error(exception)
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
......
require 'isolation/abstract_unit'
require 'stringio'
module ApplicationTests
class MiddlewareTest < Test::Unit::TestCase
......@@ -163,6 +164,25 @@ def index
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!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册