Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

deprecation warning when BufferedLogger is instantiated #8608

Merged
merged 1 commit into from

2 participants

@senny
Owner

This commit belongs to a previously merged PR #8607

ActiveSupport::BufferedLogger is not only subclassed but also instantiated. This patch adds the deprecation warning when a new BufferedLogger is instantiated.

I think this should be enough to show the user every use of the BufferedLogger. At some point there must be an instantiation or a subclass definition. This is when a deprecation warning will be shown and these are the places that need modification.

I did not add deprecation warnings to every instance method because I think this would pollute the log and would not help to track down the problematic areas.

@senny
Owner

@rafaelfranca what do you think?

@rafaelfranca rafaelfranca merged commit 227d4e9 into rails:master
@senny senny deleted the senny:8576_cant_inherit_from_deprecated_buffered_logger branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 25, 2012
  1. @senny
This page is out of date. Refresh to see the latest.
View
12 activesupport/lib/active_support/buffered_logger.rb
@@ -3,9 +3,19 @@
module ActiveSupport
class BufferedLogger < Logger
+
+ def initialize(*args)
+ self.class._deprecation_warning
+ super
+ end
+
def self.inherited(*)
- ::ActiveSupport::Deprecation.warn 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
+ _deprecation_warning
super
end
+
+ def self._deprecation_warning
+ ::ActiveSupport::Deprecation.warn 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
+ end
end
end
View
8 activesupport/test/deprecation/buffered_logger_test.rb
@@ -11,4 +11,12 @@ def test_can_be_subclassed
Class.new(ActiveSupport::BufferedLogger)
end
+ def test_issues_deprecation_when_instantiated
+ warn = 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
+
+ ActiveSupport::Deprecation.expects(:warn).with(warn).once
+
+ ActiveSupport::BufferedLogger.new(STDOUT)
+ end
+
end
Something went wrong with that request. Please try again.