aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
diff options
context:
space:
mode:
authorlest <just.lest@gmail.com>2011-11-24 22:37:48 +0300
committerlest <just.lest@gmail.com>2011-11-25 13:09:46 +0300
commitcd9d28d6fdff6819dac3c6643fe882eb568b5a39 (patch)
tree51f564da303f193576bc022a3fafae093748b445 /actionpack/lib/action_dispatch/middleware/show_exceptions.rb
parent0cd3bf84068dd2b2d0bbb26062f2cdc7093a1b04 (diff)
downloadrails-cd9d28d6fdff6819dac3c6643fe882eb568b5a39.tar.gz
rails-cd9d28d6fdff6819dac3c6643fe882eb568b5a39.tar.bz2
rails-cd9d28d6fdff6819dac3c6643fe882eb568b5a39.zip
middlewares should use logger from env
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/show_exceptions.rb')
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index 52dce4cc81..8dc2820d37 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -63,7 +63,7 @@ module ActionDispatch
private
def render_exception(env, exception)
- log_error(exception)
+ log_error(env, exception)
exception = original_exception(exception)
if env['action_dispatch.show_detailed_exceptions'] == true
@@ -124,14 +124,14 @@ module ActionDispatch
defined?(Rails.public_path) ? Rails.public_path : 'public_path'
end
- def log_error(exception)
- return unless logger
+ def log_error(env, exception)
+ return unless logger(env)
ActiveSupport::Deprecation.silence do
message = "\n#{exception.class} (#{exception.message}):\n"
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
message << " " << application_trace(exception).join("\n ")
- logger.fatal("#{message}\n\n")
+ logger(env).fatal("#{message}\n\n")
end
end
@@ -153,8 +153,12 @@ module ActionDispatch
exception.backtrace
end
- def logger
- defined?(Rails.logger) ? Rails.logger : Logger.new($stderr)
+ def logger(env)
+ env['action_dispatch.logger'] || stderr_logger
+ end
+
+ def stderr_logger
+ Logger.new($stderr)
end
def original_exception(exception)