diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index e70e99d6e..4e66b08bf 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -107,8 +107,7 @@ module Vagrant @provider_config = provider_config @provider_name = provider_name @provider_options = provider_options - @ui = @env.ui.is_a?(Vagrant::UI::MachineReadable) ? @env.ui.clone : Vagrant::UI::Prefixed.new(@env.ui, @name) - @ui.opts[:target] = name + @ui = Vagrant::UI::Prefixed.new(@env.ui, @name) @ui_mutex = Mutex.new # Read the ID, which is usually in local storage diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index c610643a9..89f412325 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -321,11 +321,18 @@ 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}"