Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4964

Show
Ignore:
Timestamp:
09/04/06 03:32:22 (2 years ago)
Author:
bitsweat
Message:

set ActiveSupport::Deprecation.debug = true to see backtraces for deprecation callers. off by default. on for Rails tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/active_support/deprecation.rb

    r4961 r4964  
     1require 'yaml' 
     2 
    13module ActiveSupport 
    24  module Deprecation 
     5    mattr_accessor :debug 
     6    self.debug = false 
     7 
    38    # Choose the default warn behavior according to RAILS_ENV. 
    49    # Ignore deprecation warnings in production. 
    510    DEFAULT_BEHAVIORS = { 
    6       'test'        => Proc.new { |message| $stderr.puts message }, 
    7       'development' => Proc.new { |message| RAILS_DEFAULT_LOGGER.warn message }, 
     11      'test'        => Proc.new { |message, callstack| 
     12                         $stderr.puts(message) 
     13                         $stderr.puts callstack.join("\n  ") if debug 
     14                       }, 
     15      'development' => Proc.new { |message, callstack| 
     16                         RAILS_DEFAULT_LOGGER.warn message 
     17                         RAILS_DEFAULT_LOGGER.debug callstack.join("\n  ") if debug 
     18                       } 
    819    } 
    920 
    1021    class << self 
    1122      def warn(message = nil, callstack = caller) 
    12         behavior.call(deprecation_message(callstack, message)) if behavior && !silenced? 
     23        behavior.call(deprecation_message(callstack, message), callstack) if behavior && !silenced? 
    1324      end 
    1425 
     
    8697          old_behavior = ActiveSupport::Deprecation.behavior 
    8798          deprecations = [] 
    88           ActiveSupport::Deprecation.behavior = Proc.new do |message
     99          ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack
    89100            deprecations << message 
    90101          end