diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-11-13 22:50:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-13 22:50:30 -0500 |
commit | f1c5b0bd0a6211286bfbb8f46991de325d45a2e5 (patch) | |
tree | fbc35fc36d87268e998f4638c35e81180f622d14 | |
parent | 2a8426c0f6f7a106ff2e6a7cec0851477e5b1c55 (diff) | |
parent | 89fab56597c335bb49887563b9a98386b5171574 (diff) | |
download | rails-f1c5b0bd0a6211286bfbb8f46991de325d45a2e5.tar.gz rails-f1c5b0bd0a6211286bfbb8f46991de325d45a2e5.tar.bz2 rails-f1c5b0bd0a6211286bfbb8f46991de325d45a2e5.zip |
Merge pull request #26222 from vipulnsward/26134-fix
Format and send logs to logger.fatal from DebugExceptions
-rw-r--r-- | actionpack/CHANGELOG.md | 8 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/debug_exceptions.rb | 6 | ||||
-rw-r--r-- | activesupport/lib/active_support/tagged_logging.rb | 11 |
3 files changed, 18 insertions, 7 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 37ccef2a78..f477d18c6a 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,11 @@ +* Fixes multiple calls to `logger.fatal` instead of a single call, + for every line in an exception backtrace, when printing trace + from `DebugExceptions` middleware. + + Fixes #26134 + + *Vipul A M* + * Add support for arbitrary hashes in strong parameters: ```ruby diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index 1a9018fe0c..1c720c5a8e 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -175,7 +175,11 @@ module ActionDispatch end def log_array(logger, array) - array.map { |line| logger.fatal line } + if logger.formatter && logger.formatter.respond_to?(:tags_text) + logger.fatal array.join("\n#{logger.formatter.tags_text}") + else + logger.fatal array.join("\n") + end end def logger(request) diff --git a/activesupport/lib/active_support/tagged_logging.rb b/activesupport/lib/active_support/tagged_logging.rb index 6836378943..ad134c49b6 100644 --- a/activesupport/lib/active_support/tagged_logging.rb +++ b/activesupport/lib/active_support/tagged_logging.rb @@ -48,13 +48,12 @@ module ActiveSupport Thread.current[thread_key] ||= [] end - private - def tags_text - tags = current_tags - if tags.any? - tags.collect { |tag| "[#{tag}] " }.join - end + def tags_text + tags = current_tags + if tags.any? + tags.collect { |tag| "[#{tag}] " }.join end + end end def self.new(logger) |