Log directly to the log file in non-verbose mode
This commit is contained in:
parent
effddda4f9
commit
2efe4cc3b5
@ -509,25 +509,22 @@ class Formula
|
|||||||
mkdir_p(logd)
|
mkdir_p(logd)
|
||||||
|
|
||||||
rd, wr = IO.pipe
|
rd, wr = IO.pipe
|
||||||
|
log = File.open(logfn, "w")
|
||||||
|
log.puts Time.now, "", cmd, args, ""
|
||||||
|
|
||||||
|
out = ARGV.verbose? ? wr : log
|
||||||
|
|
||||||
begin
|
begin
|
||||||
pid = fork { exec_cmd(cmd, args, rd, wr, logfn) }
|
pid = fork do
|
||||||
|
log.close unless out == log
|
||||||
|
exec_cmd(cmd, args, rd, out, logfn)
|
||||||
|
end
|
||||||
wr.close
|
wr.close
|
||||||
|
|
||||||
log = File.open(logfn, "w")
|
while buf = rd.gets
|
||||||
log.puts Time.now, "", cmd, args, ""
|
log.puts buf
|
||||||
|
puts buf
|
||||||
if ARGV.verbose?
|
end if ARGV.verbose?
|
||||||
while buf = rd.gets
|
|
||||||
log.puts buf
|
|
||||||
puts buf
|
|
||||||
end
|
|
||||||
elsif IO.respond_to?(:copy_stream)
|
|
||||||
IO.copy_stream(rd, log)
|
|
||||||
else
|
|
||||||
buf = ""
|
|
||||||
log.write(buf) while rd.read(1024, buf)
|
|
||||||
end
|
|
||||||
|
|
||||||
Process.wait(pid)
|
Process.wait(pid)
|
||||||
|
|
||||||
@ -548,7 +545,7 @@ class Formula
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def exec_cmd(cmd, args, rd, wr, logfn)
|
def exec_cmd(cmd, args, rd, out, logfn)
|
||||||
ENV['HOMEBREW_CC_LOG_PATH'] = logfn
|
ENV['HOMEBREW_CC_LOG_PATH'] = logfn
|
||||||
|
|
||||||
# TODO system "xcodebuild" is deprecated, this should be removed soon.
|
# TODO system "xcodebuild" is deprecated, this should be removed soon.
|
||||||
@ -564,8 +561,8 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
rd.close
|
rd.close
|
||||||
$stdout.reopen wr
|
$stdout.reopen(out)
|
||||||
$stderr.reopen wr
|
$stderr.reopen(out)
|
||||||
args.collect!{|arg| arg.to_s}
|
args.collect!{|arg| arg.to_s}
|
||||||
exec(cmd, *args) rescue nil
|
exec(cmd, *args) rescue nil
|
||||||
puts "Failed to execute: #{cmd}"
|
puts "Failed to execute: #{cmd}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user