aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@gmail.com>2015-12-16 18:31:12 -0500
committerEileen M. Uchitelle <eileencodes@gmail.com>2015-12-16 18:31:12 -0500
commite9d15072a94e2ae4dec5b7a121c84a5db38547b8 (patch)
treef580abf737de8d78b6e6cb882379befd7d7761dc /activesupport/lib/active_support
parent342221b073c82ac7ebb7349da8b1d7e1ab1c4005 (diff)
parente12ffb76ffcedd150e7d0c3dc4f93472aa4790cb (diff)
downloadrails-e9d15072a94e2ae4dec5b7a121c84a5db38547b8.tar.gz
rails-e9d15072a94e2ae4dec5b7a121c84a5db38547b8.tar.bz2
rails-e9d15072a94e2ae4dec5b7a121c84a5db38547b8.zip
Merge pull request #22592 from nwjsmith/disable-logger-message-broadcasts
Add Logger option to disable message broadcasts
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/logger.rb8
-rw-r--r--activesupport/lib/active_support/logger_silence.rb5
2 files changed, 8 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/logger.rb b/activesupport/lib/active_support/logger.rb
index 33fccdcf95..82117a64d2 100644
--- a/activesupport/lib/active_support/logger.rb
+++ b/activesupport/lib/active_support/logger.rb
@@ -1,4 +1,3 @@
-require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/logger_silence'
require 'logger'
@@ -6,16 +5,18 @@ module ActiveSupport
class Logger < ::Logger
include LoggerSilence
+ attr_accessor :broadcast_messages
+
# Broadcasts logs to multiple loggers.
def self.broadcast(logger) # :nodoc:
Module.new do
define_method(:add) do |*args, &block|
- logger.add(*args, &block)
+ logger.add(*args, &block) if broadcast_messages
super(*args, &block)
end
define_method(:<<) do |x|
- logger << x
+ logger << x if broadcast_messages
super(x)
end
@@ -44,6 +45,7 @@ module ActiveSupport
def initialize(*args)
super
@formatter = SimpleFormatter.new
+ @broadcast_messages = true
end
# Simple formatter which only displays the message.
diff --git a/activesupport/lib/active_support/logger_silence.rb b/activesupport/lib/active_support/logger_silence.rb
index a8efdef944..7d92256f24 100644
--- a/activesupport/lib/active_support/logger_silence.rb
+++ b/activesupport/lib/active_support/logger_silence.rb
@@ -1,8 +1,9 @@
require 'active_support/concern'
+require 'active_support/core_ext/module/attribute_accessors'
module LoggerSilence
extend ActiveSupport::Concern
-
+
included do
cattr_accessor :silencer
self.silencer = true
@@ -21,4 +22,4 @@ module LoggerSilence
yield self
end
end
-end \ No newline at end of file
+end