Make ohai, oh1 and odebug use #debug? and verbose? of the current object when possible.

This commit is contained in:
Markus Reiter 2020-08-02 03:22:22 +02:00
parent add10377b8
commit 75a692d08b
2 changed files with 27 additions and 9 deletions

View File

@ -939,7 +939,7 @@ class FormulaInstaller
log.mkpath if formula.plist.include? log.to_s
rescue Exception => e # rubocop:disable Lint/RescueException
onoe "Failed to install plist file"
ohai e, e.backtrace if debug?
odebug e, e.backtrace
Homebrew.failed = true
end
@ -949,7 +949,7 @@ class FormulaInstaller
onoe "Failed to fix install linkage"
puts "The formula built, but you may encounter issues using it or linking other"
puts "formulae against it."
ohai e, e.backtrace if debug?
odebug e, e.backtrace
Homebrew.failed = true
@show_summary_heading = true
end
@ -960,7 +960,7 @@ class FormulaInstaller
rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The cleaning step did not complete successfully"
puts "Still, the installation was successful, so we will link it into your prefix"
ohai e, e.backtrace if debug?
odebug e, e.backtrace
Homebrew.failed = true
@show_summary_heading = true
end
@ -996,7 +996,7 @@ class FormulaInstaller
rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The post-install step did not complete successfully"
puts "You can try again using `brew postinstall #{formula.full_name}`"
ohai e, e.backtrace if debug? || Homebrew::EnvConfig.developer?
odebug e, e.backtrace, always_display: Homebrew::EnvConfig.developer?
Homebrew.failed = true
@show_summary_heading = true
end

View File

@ -86,7 +86,13 @@ module Kernel
end
def ohai_title(title)
title = Tty.truncate(title) if $stdout.tty? && !Homebrew.args.verbose?
verbose = if respond_to?(:verbose?)
verbose?
else
Homebrew.args.verbose?
end
title = Tty.truncate(title) if $stdout.tty? && !verbose
Formatter.headline(title, color: :blue)
end
@ -95,15 +101,27 @@ module Kernel
puts sput
end
def odebug(title, *sput)
return unless Homebrew.args.debug?
def odebug(title, *sput, always_display: false)
debug = if respond_to?(:debug?)
debug?
else
Homebrew.args.debug?
end
return unless debug || always_display
puts Formatter.headline(title, color: :magenta)
puts sput unless sput.empty?
end
def oh1(title, options = {})
title = Tty.truncate(title) if $stdout.tty? && !Homebrew.args.verbose? && options.fetch(:truncate, :auto) == :auto
def oh1(title, truncate: :auto)
verbose = if respond_to?(:verbose?)
verbose?
else
Homebrew.args.verbose?
end
title = Tty.truncate(title) if $stdout.tty? && !verbose && truncate == :auto
puts Formatter.headline(title, color: :green)
end