aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2015-04-25 22:07:06 -0400
committerJack Nagel2015-04-25 23:14:05 -0400
commitbe74724ceb0b29fb75d322be50773eb2e30b0c10 (patch)
tree0561d28b33f67b82773f6a7537b795ce455b2b0e /Library
parent606127a8f43b67a4a695a5c4d3739a44b7a577d8 (diff)
downloadhomebrew-be74724ceb0b29fb75d322be50773eb2e30b0c10.tar.bz2
Add Formula#logs
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/gist-logs.rb5
-rw-r--r--Library/Homebrew/cmd/postinstall.rb5
-rw-r--r--Library/Homebrew/cmd/test.rb5
-rw-r--r--Library/Homebrew/exceptions.rb2
-rw-r--r--Library/Homebrew/formula.rb11
-rw-r--r--Library/Homebrew/formula_installer.rb7
-rw-r--r--Library/Homebrew/sandbox.rb2
7 files changed, 18 insertions, 19 deletions
diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb
index 463fcc35c..768de6714 100644
--- a/Library/Homebrew/cmd/gist-logs.rb
+++ b/Library/Homebrew/cmd/gist-logs.rb
@@ -6,7 +6,7 @@ require 'stringio'
module Homebrew
def gistify_logs f
- files = load_logs(f.name)
+ files = load_logs(f.logs)
s = StringIO.new
Homebrew.dump_verbose_config(s)
@@ -58,9 +58,8 @@ module Homebrew
request.basic_auth(user, password)
end
- def load_logs name
+ def load_logs(dir)
logs = {}
- dir = HOMEBREW_LOGS/name
dir.children.sort.each do |file|
contents = file.size? ? file.read : "empty log"
logs[file.basename.to_s] = { :content => contents }
diff --git a/Library/Homebrew/cmd/postinstall.rb b/Library/Homebrew/cmd/postinstall.rb
index 5e9e956c8..b92eb40df 100644
--- a/Library/Homebrew/cmd/postinstall.rb
+++ b/Library/Homebrew/cmd/postinstall.rb
@@ -18,9 +18,8 @@ module Homebrew
Utils.safe_fork do
if Sandbox.available? && ARGV.sandbox?
sandbox = Sandbox.new
- logd = HOMEBREW_LOGS/formula.name
- logd.mkpath
- sandbox.record_log(logd/"sandbox.postinstall.log")
+ formula.logs.mkpath
+ sandbox.record_log(formula.logs/"sandbox.postinstall.log")
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(formula)
sandbox.allow_write_cellar(formula)
diff --git a/Library/Homebrew/cmd/test.rb b/Library/Homebrew/cmd/test.rb
index 95736f3f0..8890797a8 100644
--- a/Library/Homebrew/cmd/test.rb
+++ b/Library/Homebrew/cmd/test.rb
@@ -38,9 +38,8 @@ module Homebrew
Utils.safe_fork do
if Sandbox.available? && ARGV.sandbox?
sandbox = Sandbox.new
- logd = HOMEBREW_LOGS/f.name
- logd.mkpath
- sandbox.record_log(logd/"sandbox.test.log")
+ formula.logs.mkpath
+ sandbox.record_log(formula.logs/"sandbox.test.log")
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(f)
sandbox.exec(*args)
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb
index 5b5954fe7..663236cba 100644
--- a/Library/Homebrew/exceptions.rb
+++ b/Library/Homebrew/exceptions.rb
@@ -175,7 +175,7 @@ class BuildError < RuntimeError
Homebrew.dump_build_env(env)
puts
onoe "#{formula.name} #{formula.version} did not build"
- unless (logs = Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]).empty?
+ unless (logs = Dir["#{formula.logs}/*"]).empty?
puts "Logs:"
puts logs.map{|fn| " #{fn}"}.join("\n")
end
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 1844171c9..19852beb5 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -410,6 +410,10 @@ class Formula
# there after pouring a bottle.
def bottle_prefix; prefix+'.bottle' end
+ def logs
+ HOMEBREW_LOGS+name
+ end
+
# override this to provide a plist
def plist; nil; end
alias :startup_plist :plist
@@ -510,7 +514,7 @@ class Formula
begin
yield self
ensure
- cp Dir["config.log", "CMakeCache.txt"], HOMEBREW_LOGS+name
+ cp Dir["config.log", "CMakeCache.txt"], logs
end
end
end
@@ -790,9 +794,8 @@ class Formula
@exec_count ||= 0
@exec_count += 1
- logd = HOMEBREW_LOGS/name
- logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
- mkdir_p(logd)
+ logfn = "#{logs}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
+ logs.mkpath
File.open(logfn, "w") do |log|
log.puts Time.now, "", cmd, args, ""
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 75cfa03d2..6271c08c1 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -462,7 +462,7 @@ class FormulaInstaller
end
def build
- FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]
+ FileUtils.rm_rf(formula.logs)
@start_time = Time.now
@@ -481,9 +481,8 @@ class FormulaInstaller
Utils.safe_fork do
if Sandbox.available? && ARGV.sandbox?
sandbox = Sandbox.new
- logd = HOMEBREW_LOGS/formula.name
- logd.mkpath
- sandbox.record_log(logd/"sandbox.build.log")
+ formula.logs.mkpath
+ sandbox.record_log(formula.logs/"sandbox.build.log")
sandbox.allow_write_temp_and_cache
sandbox.allow_write_log(formula)
sandbox.allow_write_cellar(formula)
diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb
index 37d579da5..f8988eef0 100644
--- a/Library/Homebrew/sandbox.rb
+++ b/Library/Homebrew/sandbox.rb
@@ -50,7 +50,7 @@ class Sandbox
end
def allow_write_log(formula)
- allow_write_path HOMEBREW_LOGS/formula.name
+ allow_write_path formula.logs
end
def deny_write_homebrew_library