aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/dispatcher.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/dispatcher.rb')
-rw-r--r--railties/lib/dispatcher.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb
index cb1289957e..398acb7e97 100644
--- a/railties/lib/dispatcher.rb
+++ b/railties/lib/dispatcher.rb
@@ -38,13 +38,14 @@ class Dispatcher
controller = ActionController::Routing::Routes.recognize(request)
controller.process(request, response).out(output)
end
- rescue Exception => exception # errors from CGI dispatch
+ rescue Exception => exception # errors from CGI dispatch
failsafe_response(cgi, output, '500 Internal Server Error', exception) do
controller ||= (ApplicationController rescue ActionController::Base)
controller.process_with_exception(request, response, exception).out(output)
end
ensure
- # Do not give a failsafe response here.
+ # Do not give a failsafe response here
+ flush_logger
reset_after_dispatch
end
@@ -165,9 +166,13 @@ class Dispatcher
if defined?(RAILS_DEFAULT_LOGGER) && !RAILS_DEFAULT_LOGGER.nil?
RAILS_DEFAULT_LOGGER
else
- Logger.new($stderr)
+ ActiveSupport::BufferedLogger.new($stderr)
end
end
+
+ def flush_logger
+ RAILS_DEFAULT_LOGGER.flush if defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:flush)
+ end
end
end