From 96e4544949c3ed238e642cb3bb6321cc226e1890 Mon Sep 17 00:00:00 2001 From: Austin Schutz Date: Mon, 7 Jul 2014 14:31:45 -0700 Subject: [PATCH] use env.ui for action logging --- lib/vagrant/machine.rb | 3 +-- lib/vagrant/ui.rb | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) 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}"