Merge pull request #20433 from Homebrew/formula-logfn
formula: improve log filename handling
This commit is contained in:
commit
a8aa3590f2
@ -3067,14 +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",
|
||||
logfn = 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
|
||||
|
||||
# Append `.log` here instead of in the definition of `logfn` to avoid
|
||||
# log files named `xy.cmake.log.cc.log` from `shims/super/cc`.
|
||||
File.open("#{logfn}.log", "w") do |log|
|
||||
File.open(logfn, "w") do |log|
|
||||
log.puts Time.now, "", cmd, args, ""
|
||||
log.flush
|
||||
|
||||
|
@ -524,6 +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"
|
||||
adds = args - argv
|
||||
dels = argv - args
|
||||
|
||||
@ -532,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("#{ENV["HOMEBREW_CC_LOG_PATH"]}.cc.log", "a+") { |f| f.write(s) }
|
||||
File.open(logfn, "a+") { |f| f.write(s) }
|
||||
end
|
||||
|
||||
def remove_superbin_from_path(paths)
|
||||
|
Loading…
x
Reference in New Issue
Block a user