use env.ui for action logging

This commit is contained in:
Austin Schutz 2014-07-07 14:31:45 -07:00 committed by Mitchell Hashimoto
parent 566e21d3fc
commit 96e4544949
2 changed files with 8 additions and 2 deletions

View File

@ -107,8 +107,7 @@ module Vagrant
@provider_config = provider_config @provider_config = provider_config
@provider_name = provider_name @provider_name = provider_name
@provider_options = provider_options @provider_options = provider_options
@ui = @env.ui.is_a?(Vagrant::UI::MachineReadable) ? @env.ui.clone : Vagrant::UI::Prefixed.new(@env.ui, @name) @ui = Vagrant::UI::Prefixed.new(@env.ui, @name)
@ui.opts[:target] = name
@ui_mutex = Mutex.new @ui_mutex = Mutex.new
# Read the ID, which is usually in local storage # Read the ID, which is usually in local storage

View File

@ -321,11 +321,18 @@ 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}"