Class: Legion::Logging::MultiIO

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/logging/multi_io.rb

Instance Method Summary collapse

Constructor Details

#initialize(*targets) ⇒ MultiIO

Returns a new instance of MultiIO.



6
7
8
# File 'lib/legion/logging/multi_io.rb', line 6

def initialize(*targets)
  @targets = targets.flatten
end

Instance Method Details

#closeObject



16
17
18
# File 'lib/legion/logging/multi_io.rb', line 16

def close
  @targets.each { |t| t.close unless [$stdout, $stderr].include?(t) }
end

#flushObject



20
21
22
# File 'lib/legion/logging/multi_io.rb', line 20

def flush
  @targets.each { |t| t.flush if t.respond_to?(:flush) }
end

#write(message) ⇒ Object



10
11
12
13
14
# File 'lib/legion/logging/multi_io.rb', line 10

def write(message)
  @targets.each do |t|
    t.write(message)
  end
end