diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-20 11:45:29 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-20 11:57:07 -0800 |
commit | d42b3d4347547b7790d0a716e7548baccf408076 (patch) | |
tree | b899316957a7593d86bae2847bebf75e0f87154a /activesupport/lib | |
parent | 30b0e5848c5a91c0bfd1ef33ec4b9bc36bcead0b (diff) | |
download | rails-d42b3d4347547b7790d0a716e7548baccf408076.tar.gz rails-d42b3d4347547b7790d0a716e7548baccf408076.tar.bz2 rails-d42b3d4347547b7790d0a716e7548baccf408076.zip |
add a broadcasting logger so we can split logs
Diffstat (limited to 'activesupport/lib')
-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 |