Module: Stump::Logger

Defined in:
lib/stump.rb

Class Method Summary collapse

Class Method Details

.new(path = nil) ⇒ Object

Initialize a new Logger with the desired targets: either STDOUT, a log file or both. path is an array of file paths.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/stump.rb', line 15

def self.new(path=nil)
  return ::Logger.new(LoggerTargets.new(STDOUT)) unless path

  if FileTest.exist?(path)
    log_file = File.open(path, 'a')
  else
    FileUtils.mkdir_p(File.dirname(path))
    log_file = File.new(path, 'w')
  end

  ::Logger.new LoggerTargets.new(STDOUT, log_file)
end