aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/lib/active_support/buffered_logger.rb12
-rw-r--r--activesupport/test/deprecation/buffered_logger_test.rb8
2 files changed, 19 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/buffered_logger.rb b/activesupport/lib/active_support/buffered_logger.rb
index 2e63e67262..1cd0c2f790 100644
--- a/activesupport/lib/active_support/buffered_logger.rb
+++ b/activesupport/lib/active_support/buffered_logger.rb
@@ -3,9 +3,19 @@ require 'active_support/logger'
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
diff --git a/activesupport/test/deprecation/buffered_logger_test.rb b/activesupport/test/deprecation/buffered_logger_test.rb
index 1082ecef23..bf11a4732c 100644
--- a/activesupport/test/deprecation/buffered_logger_test.rb
+++ b/activesupport/test/deprecation/buffered_logger_test.rb
@@ -11,4 +11,12 @@ class BufferedLoggerTest < ActiveSupport::TestCase
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