core: fix machine readable UI to contain target and have proper format
This commit is contained in:
parent
a87dec60ad
commit
cee517d963
|
@ -104,8 +104,8 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
[:detail, :warn, :error, :info, :output, :success].each do |method|
|
[:detail, :warn, :error, :info, :output, :success].each do |method|
|
||||||
define_method(method) do |message, *opts|
|
define_method(method) do |message, *args, **opts|
|
||||||
machine("ui", method.to_s, message)
|
machine("ui", method.to_s, message, *args, **opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -280,6 +280,8 @@ module Vagrant
|
||||||
opts[:bold] = #{method.inspect} != :detail && \
|
opts[:bold] = #{method.inspect} != :detail && \
|
||||||
#{method.inspect} != :ask
|
#{method.inspect} != :ask
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts[:target] = @prefix
|
||||||
@ui.#{method}(format_message(#{method.inspect}, message, **opts), *args, **opts)
|
@ui.#{method}(format_message(#{method.inspect}, message, **opts), *args, **opts)
|
||||||
end
|
end
|
||||||
CODE
|
CODE
|
||||||
|
@ -324,17 +326,11 @@ module Vagrant
|
||||||
target = opts[:target] if opts.key?(:target)
|
target = opts[:target] if opts.key?(:target)
|
||||||
target = "#{target}:" if target != ""
|
target = "#{target}:" if target != ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Get the lines. The first default is because if the message
|
# Get the lines. The first default is because if the message
|
||||||
# is an empty string, then we want to still use the empty string.
|
# is an empty string, then we want to still use the empty string.
|
||||||
lines = [message]
|
lines = [message]
|
||||||
lines = message.split("\n") if 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
|
# Otherwise, make sure to prefix every line properly
|
||||||
lines.map do |line|
|
lines.map do |line|
|
||||||
"#{prefix}#{target} #{line}"
|
"#{prefix}#{target} #{line}"
|
||||||
|
|
Loading…
Reference in New Issue