Merge pull request #20438 from Homebrew/formula-logfn

formula: improve variable naming
This commit is contained in:
Ruoyu Zhong 2025-08-13 07:46:30 +00:00 committed by GitHub
commit efae78dc96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 16 deletions

View File

@ -3067,12 +3067,12 @@ class Formula
@exec_count ||= T.let(0, T.nilable(Integer))
@exec_count += 1
logfn = format("#{logs}/#{active_log_prefix}%02<exec_count>d.%<cmd_base>s.log",
log_filename = format("#{logs}/#{active_log_prefix}%02<exec_count>d.%<cmd_base>s.log",
exec_count: @exec_count,
cmd_base: File.basename(cmd).split.first)
logs.mkpath
File.open(logfn, "w") do |log|
File.open(log_filename, "w") do |log|
log.puts Time.now, "", cmd, args, ""
log.flush
@ -3082,7 +3082,7 @@ class Formula
pid = fork do
rd.close
log.close
exec_cmd(cmd, args, wr, logfn)
exec_cmd(cmd, args, wr, log_filename)
end
wr.close
@ -3109,7 +3109,7 @@ class Formula
end
else
pid = fork do
exec_cmd(cmd, args, log, logfn)
exec_cmd(cmd, args, log, log_filename)
end
end
@ -3122,8 +3122,8 @@ class Formula
log.flush
if !verbose? || verbose_using_dots
puts "Last #{log_lines} lines from #{logfn}:"
Kernel.system "/usr/bin/tail", "-n", log_lines.to_s, logfn
puts "Last #{log_lines} lines from #{log_filename}:"
Kernel.system "/usr/bin/tail", "-n", log_lines.to_s, log_filename
end
log.puts
@ -3267,11 +3267,11 @@ class Formula
cmd: T.any(String, Pathname),
args: T::Array[T.any(String, Integer, Pathname, Symbol)],
out: IO,
logfn: T.nilable(String),
log_filename: T.nilable(String),
).void
}
def exec_cmd(cmd, args, out, logfn)
ENV["HOMEBREW_CC_LOG_PATH"] = logfn
def exec_cmd(cmd, args, out, log_filename)
ENV["HOMEBREW_CC_LOG_PATH"] = log_filename
ENV.remove_cc_etc if cmd.to_s.start_with? "xcodebuild"

View File

@ -524,7 +524,7 @@ end
def log(basename, argv, tool, args)
return unless ENV.key?("HOMEBREW_CC_LOG_PATH")
logfn = "#{ENV["HOMEBREW_CC_LOG_PATH"].delete_suffix(".log")}.cc.log"
log_filename = "#{ENV["HOMEBREW_CC_LOG_PATH"].delete_suffix(".log")}.cc.log"
adds = args - argv
dels = argv - args
@ -533,7 +533,7 @@ def log(basename, argv, tool, args)
s << "superenv removed: #{dels.join(" ")}\n" unless dels.empty?
s << "superenv added: #{adds.join(" ")}\n" unless adds.empty?
s << "superenv executed: #{tool} #{args.join(" ")}\n\n"
File.open(logfn, "a+") { |f| f.write(s) }
File.open(log_filename, "a+") { |f| f.write(s) }
end
def remove_superbin_from_path(paths)