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.



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

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

Instance Method Details

#closeObject



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

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

#write(*args) ⇒ Object



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

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