diff options
| author | Stefan | 2013-10-27 07:05:13 +0100 |
|---|---|---|
| committer | Jack Nagel | 2013-10-31 14:24:48 -0500 |
| commit | fb749e47509b77b5bd89e7b14f0a1097d4af7f40 (patch) | |
| tree | e6d271b184d906e86b7b0d38d64b0ddd06004047 | |
| parent | c57bf7ef17a7c1996520d614707d182f7d92f05a (diff) | |
| download | homebrew-fb749e47509b77b5bd89e7b14f0a1097d4af7f40.tar.bz2 | |
Generate logs in verbose mode
Closes #23654.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
| -rw-r--r-- | Library/Homebrew/formula.rb | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 12da44c18..efdc65416 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -567,40 +567,39 @@ class Formula ENV.remove_cc_etc end - if ARGV.verbose? - safe_system cmd, *args - else - @exec_count ||= 0 - @exec_count += 1 - logd = HOMEBREW_LOGS/name - logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd.to_s).split(' ').first] - mkdir_p(logd) - - rd, wr = IO.pipe - fork do - rd.close - $stdout.reopen wr - $stderr.reopen wr - args.collect!{|arg| arg.to_s} - exec(cmd.to_s, *args) rescue nil - puts "Failed to execute: #{cmd}" - exit! 1 # never gets here unless exec threw or failed + @exec_count ||= 0 + @exec_count += 1 + logd = HOMEBREW_LOGS/name + logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd.to_s).split(' ').first] + mkdir_p(logd) + + rd, wr = IO.pipe + fork do + rd.close + $stdout.reopen wr + $stderr.reopen wr + args.collect!{|arg| arg.to_s} + exec(cmd.to_s, *args) rescue nil + puts "Failed to execute: #{cmd}" + exit! 1 # never gets here unless exec threw or failed + end + wr.close + + File.open(logfn, 'w') do |f| + while buf = rd.gets + f.puts buf + puts buf if ARGV.verbose? end - wr.close - - File.open(logfn, 'w') do |f| - f.write(rd.read) until rd.eof? - Process.wait + Process.wait - unless $?.success? - f.flush - Kernel.system "/usr/bin/tail", "-n", "5", logfn - f.puts - require 'cmd/--config' - Homebrew.write_build_config(f) - raise ErrorDuringExecution - end + unless $?.success? + f.flush + Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose? + f.puts + require 'cmd/--config' + Homebrew.write_build_config(f) + raise ErrorDuringExecution end end rescue ErrorDuringExecution |
