aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/railtie.rb
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-06-29 12:18:17 -0700
committerwycats <wycats@gmail.com>2010-06-29 12:20:15 -0700
commitd4c7d3fd94e5a885a6366eaeb3b908bb58ffd4db (patch)
tree83eb729393ddffc4fb06f6c49c96c9bf758220e6 /activesupport/lib/active_support/railtie.rb
parent21957b72ea394c679d9b17e75b570cc99596322d (diff)
downloadrails-d4c7d3fd94e5a885a6366eaeb3b908bb58ffd4db.tar.gz
rails-d4c7d3fd94e5a885a6366eaeb3b908bb58ffd4db.tar.bz2
rails-d4c7d3fd94e5a885a6366eaeb3b908bb58ffd4db.zip
Create a deprecation behavior that triggers a notification for deprecation notices, and make the behaviors independent of the environment names.
* In Rails 2.3 apps being upgraded, you will need to add the deprecation configuration to each of your environments. Failing to do so will result in the same behavior as Rails 2.3, but with an outputted warning to provide information on how to set up the setting. * New Rails 3 applications generate the setting * The notification style will send deprecation notices using ActiveSupport::Notifications. Third-party tools can listen in to these notifications to provide a streamlined view of the deprecation notices occurring in your app. * The payload in the notification is the deprecation warning itself as well as the callstack from the point that triggered the notification.
Diffstat (limited to 'activesupport/lib/active_support/railtie.rb')
-rw-r--r--activesupport/lib/active_support/railtie.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb
index 1f32f8718f..7970d39faf 100644
--- a/activesupport/lib/active_support/railtie.rb
+++ b/activesupport/lib/active_support/railtie.rb
@@ -12,6 +12,34 @@ module ActiveSupport
require 'active_support/whiny_nil' if app.config.whiny_nils
end
+ initializer "active_support.deprecation_behavior" do |app|
+ if deprecation = app.config.active_support.deprecation
+ ActiveSupport::Deprecation.behavior = deprecation
+ else
+ defaults = {"development" => :log,
+ "production" => :notify,
+ "test" => :stderr}
+
+ env = Rails.env
+
+ if defaults.key?(env)
+ msg = "You did not specify how you would like Rails to report " \
+ "deprecation notices for your #{env} environment, please " \
+ "set it to :#{defaults[env]} at config/environments/#{env}.rb"
+
+ warn msg
+ ActiveSupport::Deprecation.behavior = defaults[env]
+ else
+ msg = "You did not specify how you would like Rails to report " \
+ "deprecation notices for your #{env} environment, please " \
+ "set it to :log, :notify or :stderr at config/environments/#{env}.rb"
+
+ warn msg
+ ActiveSupport::Deprecation.behavior = :stderr
+ end
+ end
+ end
+
# Sets the default value for Time.zone
# If assigned value cannot be matched to a TimeZone, an exception will be raised.
initializer "active_support.initialize_time_zone" do |app|