Permalink
Browse files

set ActiveSupport::Deprecation.debug = true to see backtraces for dep…

…recation callers. off by default. on for Rails tests.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4964 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 25ea18a commit 6ca6c5de3ab8a60a384d0d3a91877ab83b749835 @jeremy jeremy committed Sep 4, 2006
Showing with 15 additions and 4 deletions.
  1. +15 −4 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 @@ def assert_not_deprecated(&block)
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

0 comments on commit 6ca6c5d

Please sign in to comment.