diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-25 03:47:37 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-09-25 03:47:37 +0000 |
commit | 79a9c7a702f4bccb2af5c82bb9a78209b28ab1c7 (patch) | |
tree | abdd87ec54e111b54198cb70728e224da5bc3cfb /railties/lib/dispatcher.rb | |
parent | 501244fee4045dd7a48b8753e9f54a060fdc743d (diff) | |
download | rails-79a9c7a702f4bccb2af5c82bb9a78209b28ab1c7.tar.gz rails-79a9c7a702f4bccb2af5c82bb9a78209b28ab1c7.tar.bz2 rails-79a9c7a702f4bccb2af5c82bb9a78209b28ab1c7.zip |
Added ActiveSupport::BufferedLogger as a duck-typing alternative (albeit with no formatter) to the Ruby Logger, which provides a very nice speed bump (inspired by Ezra's buffered logger) [DHH] Changed the default logger from Ruby's own Logger with the clean_logger extensions to ActiveSupport::BufferedLogger for performance reasons [DHH]. (You can change it back with config.logger = Logger.new(/path/to/log, level).)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7626 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/dispatcher.rb')
-rw-r--r-- | railties/lib/dispatcher.rb | 11 |
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 |