From 6ca6c5de3ab8a60a384d0d3a91877ab83b749835 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 4 Sep 2006 03:32:22 +0000 Subject: 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 --- activesupport/lib/active_support/deprecation.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'activesupport/lib/active_support') 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 -- cgit v1.2.3