core: fix machine readable UI to contain target and have proper format

This commit is contained in:
Mitchell Hashimoto 2015-12-01 16:59:06 -08:00
parent a87dec60ad
commit cee517d963
1 changed files with 4 additions and 8 deletions

View File

@ -104,8 +104,8 @@ module Vagrant
end
[:detail, :warn, :error, :info, :output, :success].each do |method|
define_method(method) do |message, *opts|
machine("ui", method.to_s, message)
define_method(method) do |message, *args, **opts|
machine("ui", method.to_s, message, *args, **opts)
end
end
@ -280,6 +280,8 @@ module Vagrant
opts[:bold] = #{method.inspect} != :detail && \
#{method.inspect} != :ask
end
opts[:target] = @prefix
@ui.#{method}(format_message(#{method.inspect}, message, **opts), *args, **opts)
end
CODE
@ -324,17 +326,11 @@ module Vagrant
target = opts[:target] if opts.key?(:target)
target = "#{target}:" if target != ""
# Get the lines. The first default is because if the message
# is an empty string, then we want to still use the empty string.
lines = [message]
lines = message.split("\n") if message != ""
if @ui.is_a?(Vagrant::UI::MachineReadable)
return machine(type, message, { :target => target })
end
# Otherwise, make sure to prefix every line properly
lines.map do |line|
"#{prefix}#{target} #{line}"