From 0b2c49aa4dad73d2af098bbbd545c05ed2ace3cd Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Wed, 28 Nov 2018 16:45:31 +1100 Subject: Log exceptions atomically When distributed over multiple logger calls the lines can become intermixed with other log statements. Combining them into a single logger call makes sure they always get logged together. --- .../lib/action_dispatch/middleware/debug_exceptions.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index 5f5fdbc66a..61e7e73a68 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -180,11 +180,14 @@ module ActionDispatch trace = wrapper.framework_trace if trace.empty? ActiveSupport::Deprecation.silence do - logger.fatal " " - logger.fatal "#{exception.class} (#{exception.message}):" - log_array logger, exception.annoted_source_code if exception.respond_to?(:annoted_source_code) - logger.fatal " " - log_array logger, trace + message = [] + message << " " + message << "#{exception.class} (#{exception.message}):" + message += exception.annoted_source_code if exception.respond_to?(:annoted_source_code) + message << " " + message += trace + + log_array(logger, message) end end -- cgit v1.2.3 From acbc0e0467e7d4b7075c7b2df6404d807ba7d06c Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Thu, 29 Nov 2018 09:14:24 +1100 Subject: Avoid extra array allocations --- actionpack/lib/action_dispatch/middleware/debug_exceptions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index 61e7e73a68..7669767ae3 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -183,9 +183,9 @@ module ActionDispatch message = [] message << " " message << "#{exception.class} (#{exception.message}):" - message += exception.annoted_source_code if exception.respond_to?(:annoted_source_code) + message.concat(exception.annoted_source_code) if exception.respond_to?(:annoted_source_code) message << " " - message += trace + message.concat(trace) log_array(logger, message) end -- cgit v1.2.3