lib/autobuild/subcommand.rb in autobuild-1.5.0 vs lib/autobuild/subcommand.rb in autobuild-1.5.1

- old
+ new

@@ -1,10 +1,28 @@ +require 'set' require 'autobuild/exceptions' require 'autobuild/reporting' require 'fcntl' module Autobuild + @logfiles = Set.new + def self.clear_logfiles + @logfiles.clear + end + + def self.logfiles + @logfiles + end + + def self.register_logfile(path) + @logfiles << path + end + + def self.registered_logfile?(logfile) + @logfiles.include?(logfile) + end + @parallel_build_level = nil class << self # Sets the level of parallelism during the build # # See #parallel_build_level for detailed information @@ -79,11 +97,11 @@ logdir = if target.respond_to?(:logdir) target.logdir else Autobuild.logdir end - logname = "#{logdir}/#{target_name}-#{phase}.log" + logname = File.join(logdir, "#{target_name}-#{phase}.log") if !File.directory?(File.dirname(logname)) FileUtils.mkdir_p File.dirname(logname) end if Autobuild.verbose @@ -92,11 +110,14 @@ input_streams = command.collect { |o| $1 if o =~ /^\<(.+)/ }.compact command.reject! { |o| o =~ /^\<(.+)/ } open_flag = if Autobuild.keep_oldlogs then 'a' + elsif Autobuild.registered_logfile?(logname) then 'a' else 'w' end + + Autobuild.register_logfile(logname) status = File.open(logname, open_flag) do |logfile| if Autobuild.keep_oldlogs logfile.puts end