Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure that ActiveSupport::Logger includes the Logger extensions f…

…rom core_ext/logger
  • Loading branch information...
commit d00f568a83a5159ed93618b1081bd17858536d1c 1 parent f914454
David Heinemeier Hansson dhh authored
2  activesupport/CHANGELOG.md
View
@@ -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*
21 activesupport/lib/active_support/core_ext/logger.rb
View
@@ -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 @@ def around_#{level}(before_message, after_message) # def around_debug(before_me
#
# 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
4 activesupport/lib/active_support/logger.rb
View
@@ -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
24 activesupport/lib/active_support/logger_silence.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.