From 718b82560a3c9c61391dddf582d28b648c143e2a Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Mon, 11 Aug 2025 13:10:14 +0800 Subject: [PATCH] formula: append `.log` to formula build log filenames Having log files with extensions like `.cc` and `.cmake` is really unfriendly to editor syntax highlighters and language servers. Let's try to make sure these are opened as log files by adding a `.log` extension to them. --- Library/Homebrew/formula.rb | 4 +++- Library/Homebrew/shims/super/cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 525fc58f9c..e023501b22 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -3067,7 +3067,9 @@ class Formula cmd_base: File.basename(cmd).split.first) logs.mkpath - File.open(logfn, "w") do |log| + # 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| log.puts Time.now, "", cmd, args, "" log.flush diff --git a/Library/Homebrew/shims/super/cc b/Library/Homebrew/shims/super/cc index 1bb5950b39..ce8505b08f 100755 --- a/Library/Homebrew/shims/super/cc +++ b/Library/Homebrew/shims/super/cc @@ -532,7 +532,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", "a+") { |f| f.write(s) } + File.open("#{ENV["HOMEBREW_CC_LOG_PATH"]}.cc.log", "a+") { |f| f.write(s) } end def remove_superbin_from_path(paths)