class ParallelTests::RSpec::LoggerBase

def close(*)

stolen from Rspec
def close(*)
  @output.close if (IO === @output) & (@output != $stdout)
end

def initialize(*args)

def initialize(*args)
  super
  @output ||= args[0]
  case @output
  when String # a path ?
    FileUtils.mkdir_p(File.dirname(@output))
    File.open(@output, 'w') {} # overwrite previous results
    @output = File.open(@output, 'a')
  when File # close and restart in append mode
    @output.close
    @output = File.open(@output.path, 'a')
  end
end

def lock_output

do not let multiple processes get in each others way
def lock_output
  if @output.is_a?(File)
    begin
      @output.flock File::LOCK_EX
      yield
    ensure
      @output.flock File::LOCK_UN
    end
  else
    yield
  end
end