aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2012-12-21 19:28:24 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2012-12-21 19:28:24 +0100
commitd00f568a83a5159ed93618b1081bd17858536d1c (patch)
tree67983dd6038148f9da162f2aa8ed9926b336874d
parentf914454f3af46a011d2ea627925cadea73f62e92 (diff)
downloadrails-d00f568a83a5159ed93618b1081bd17858536d1c.tar.gz
rails-d00f568a83a5159ed93618b1081bd17858536d1c.tar.bz2
rails-d00f568a83a5159ed93618b1081bd17858536d1c.zip
Make sure that ActiveSupport::Logger includes the Logger extensions from core_ext/logger
-rw-r--r--activesupport/CHANGELOG.md2
-rw-r--r--activesupport/lib/active_support/core_ext/logger.rb21
-rw-r--r--activesupport/lib/active_support/logger.rb4
-rw-r--r--activesupport/lib/active_support/logger_silence.rb24
4 files changed, 21 insertions, 30 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 1d11ae2afd..df18b7540b 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,6 +1,6 @@
## Rails 4.0.0 (unreleased) ##
-* Add ActiveSupport::Logger#silence that works the same as the old Logger#silence extension.
+* Make sure that ActiveSupport::Logger includes the Logger extensions from core_ext/logger.
*DHH*
diff --git a/activesupport/lib/active_support/core_ext/logger.rb b/activesupport/lib/active_support/core_ext/logger.rb
index 36c8f241b2..16fce81445 100644
--- a/activesupport/lib/active_support/core_ext/logger.rb
+++ b/activesupport/lib/active_support/core_ext/logger.rb
@@ -1,6 +1,5 @@
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/deprecation'
-require 'active_support/logger_silence'
ActiveSupport::Deprecation.warn 'this file is deprecated and will be removed'
@@ -34,7 +33,25 @@ require 'logger'
#
# Note: This logger is deprecated in favor of ActiveSupport::BufferedLogger
class Logger
- include LoggerSilence
+ ##
+ # :singleton-method:
+ # Set to false to disable the silencer
+ cattr_accessor :silencer
+ self.silencer = true
+
+ # Silences the logger for the duration of the block.
+ def silence(temporary_level = Logger::ERROR)
+ if silencer
+ begin
+ old_logger_level, self.level = level, temporary_level
+ yield self
+ ensure
+ self.level = old_logger_level
+ end
+ else
+ yield self
+ end
+ end
alias :old_datetime_format= :datetime_format=
# Logging date-time format (string passed to +strftime+). Ignored if the formatter
diff --git a/activesupport/lib/active_support/logger.rb b/activesupport/lib/active_support/logger.rb
index 4a55bbb350..023e22e642 100644
--- a/activesupport/lib/active_support/logger.rb
+++ b/activesupport/lib/active_support/logger.rb
@@ -1,11 +1,9 @@
require 'active_support/core_ext/class/attribute_accessors'
-require 'active_support/logger_silence'
require 'logger'
+require 'active_support/core_ext/logger'
module ActiveSupport
class Logger < ::Logger
- include LoggerSilence
-
# Broadcasts logs to multiple loggers.
def self.broadcast(logger) # :nodoc:
Module.new do
diff --git a/activesupport/lib/active_support/logger_silence.rb b/activesupport/lib/active_support/logger_silence.rb
deleted file mode 100644
index a8efdef944..0000000000
--- a/activesupport/lib/active_support/logger_silence.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'active_support/concern'
-
-module LoggerSilence
- extend ActiveSupport::Concern
-
- included do
- cattr_accessor :silencer
- self.silencer = true
- end
-
- # Silences the logger for the duration of the block.
- def silence(temporary_level = Logger::ERROR)
- if silencer
- begin
- old_logger_level, self.level = level, temporary_level
- yield self
- ensure
- self.level = old_logger_level
- end
- else
- yield self
- end
- end
-end \ No newline at end of file