Class: Legion::Logging::MultiIO
- Inherits:
-
Object
- Object
- Legion::Logging::MultiIO
- Defined in:
- lib/legion/logging/multi_io.rb
Instance Method Summary collapse
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize(*targets) ⇒ MultiIO
constructor
A new instance of MultiIO.
- #write(message) ⇒ Object
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
#close ⇒ Object
18 19 20 |
# File 'lib/legion/logging/multi_io.rb', line 18 def close @targets.each { |t| t.close unless [$stdout, $stderr].include?(t) } end |
#flush ⇒ Object
22 23 24 |
# File 'lib/legion/logging/multi_io.rb', line 22 def flush @targets.each { |t| t.flush if t.respond_to?(:flush) } end |
#write(message) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/legion/logging/multi_io.rb', line 10 def write() @targets.each do |t| t.write() rescue StandardError => e warn("Legion::Logging::MultiIO#write failed for #{t.class}: #{e.}") end end |