diff options
Diffstat (limited to 'activesupport/lib/active_support/logger.rb')
-rw-r--r-- | activesupport/lib/active_support/logger.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/logger.rb b/activesupport/lib/active_support/logger.rb index 66e8fcadb4..8288368d8d 100644 --- a/activesupport/lib/active_support/logger.rb +++ b/activesupport/lib/active_support/logger.rb @@ -1,6 +1,29 @@ require 'logger' module ActiveSupport + # Broadcasts logs to multiple loggers + class BroadcastLogger < ::Logger # :nodoc: + attr_reader :logs + + def initialize(logs) + super(nil) + @logs = logs + end + + def add(severity, message = nil, progname = nil, &block) + super + logs.each { |l| l.add(severity, message, progname, &block) } + end + + def <<(x) + logs.each { |l| l << x } + end + + def close + logs.each(&:close) + end + end + class Logger < ::Logger def initialize(*args) super |