module Stump::Logger

Public Class Methods

new(path=nil) click to toggle source

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

# 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