diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-09-04 03:32:22 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-09-04 03:32:22 +0000 |
commit | 6ca6c5de3ab8a60a384d0d3a91877ab83b749835 (patch) | |
tree | 02677785c1faba3f769f91a90347bec0cc1f698c /activesupport/lib | |
parent | 25ea18aa150c7eb26fd09ab6ab26eb455fac7ff0 (diff) | |
download | rails-6ca6c5de3ab8a60a384d0d3a91877ab83b749835.tar.gz rails-6ca6c5de3ab8a60a384d0d3a91877ab83b749835.tar.bz2 rails-6ca6c5de3ab8a60a384d0d3a91877ab83b749835.zip |
set ActiveSupport::Deprecation.debug = true to see backtraces for deprecation callers. off by default. on for Rails tests.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4964 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/deprecation.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 2cfbfcc21a..f6dc863e41 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -1,15 +1,26 @@ +require 'yaml' + module ActiveSupport module Deprecation + mattr_accessor :debug + self.debug = false + # Choose the default warn behavior according to RAILS_ENV. # Ignore deprecation warnings in production. DEFAULT_BEHAVIORS = { - 'test' => Proc.new { |message| $stderr.puts message }, - 'development' => Proc.new { |message| RAILS_DEFAULT_LOGGER.warn message }, + 'test' => Proc.new { |message, callstack| + $stderr.puts(message) + $stderr.puts callstack.join("\n ") if debug + }, + 'development' => Proc.new { |message, callstack| + RAILS_DEFAULT_LOGGER.warn message + RAILS_DEFAULT_LOGGER.debug callstack.join("\n ") if debug + } } class << self def warn(message = nil, callstack = caller) - behavior.call(deprecation_message(callstack, message)) if behavior && !silenced? + behavior.call(deprecation_message(callstack, message), callstack) if behavior && !silenced? end def default_behavior @@ -85,7 +96,7 @@ module ActiveSupport def collect_deprecations old_behavior = ActiveSupport::Deprecation.behavior deprecations = [] - ActiveSupport::Deprecation.behavior = Proc.new do |message| + ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack| deprecations << message end yield |