aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-11-25 05:33:26 -0800
committerJosé Valim <jose.valim@gmail.com>2011-11-25 05:33:26 -0800
commit6f5fdf81799d3d7596ca3821b1c04ce2b36fcd87 (patch)
treec416c734c04790ccf7563fe48a02d7f61abfe41b /actionpack/lib/action_dispatch/middleware/show_exceptions.rb
parent8ff8fa5e5fd9a615f2c63f809a2747a55cd4da15 (diff)
parentcd9d28d6fdff6819dac3c6643fe882eb568b5a39 (diff)
downloadrails-6f5fdf81799d3d7596ca3821b1c04ce2b36fcd87.tar.gz
rails-6f5fdf81799d3d7596ca3821b1c04ce2b36fcd87.tar.bz2
rails-6f5fdf81799d3d7596ca3821b1c04ce2b36fcd87.zip
Merge pull request #3747 from lest/middleware-logger
middlewares should have configurable logger
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)