Class: Awestruct::AwestructLoggerMultiIO

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(log_to_debug_io = false, *targets) ⇒ AwestructLoggerMultiIO

Returns a new instance of AwestructLoggerMultiIO.



6
7
8
9
# File 'lib/awestruct/logger.rb', line 6

def initialize(log_to_debug_io = false, *targets)
  @targets = targets
  @log_to_debug = log_to_debug_io
end

Instance Method Details

#closeObject



22
23
24
# File 'lib/awestruct/logger.rb', line 22

def close
  @targs.each(&:close)
end

#write(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/awestruct/logger.rb', line 11

def write(*args)
  @targets.each do |target|
    if target.instance_of?(File) && @log_to_debug
      target.write(*args)
    end
    if args[0][0] != '[' && target.instance_of?(IO)
      target.write(*args)
    end
  end
end