Skip to content

Commit

Permalink
feat: output complete logs on error, including "config.log"
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Apr 30, 2023
1 parent 5f14c02 commit f8df989
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def configure
# Windows doesn't recognize the shebang.
command.unshift("sh")
end
execute('configure', command + computed_options)
execute('configure', command + computed_options, altlog: "config.log")
end

def compile
Expand Down Expand Up @@ -420,6 +420,7 @@ def execute(action, command, command_opts={})
opt_debug = command_opts.fetch(:debug, false)
opt_cd = command_opts.fetch(:cd) { work_path }
opt_env = command_opts.fetch(:env) { Hash.new }
opt_altlog = command_opts.fetch(:altlog, nil)

log_out = log_file(action)

Expand Down Expand Up @@ -450,12 +451,12 @@ def execute(action, command, command_opts={})
output "OK"
return true
else
if File.exist? log_out
output "ERROR, review '#{log_out}' to see what happened. Last lines are:"
output("=" * 72)
log_lines = File.readlines(log_out)
output(log_lines[-[log_lines.length, 20].min .. -1])
output("=" * 72)
output "ERROR. Please review logs to see what happened:\n"
[log_out, opt_altlog].compact.each do |log|
next unless File.exist?(log)
output("----- contents of '#{log}' -----")
output(File.read(log))
output("----- end of file -----")
end
raise "Failed to complete #{action} task"
end
Expand Down

0 comments on commit f8df989

Please sign in to comment.