Resource prefixes in UI output work

This commit is contained in:
Mitchell Hashimoto 2011-12-10 16:17:09 -08:00
parent 40b9254d5a
commit baba6af4ff
3 changed files with 19 additions and 7 deletions

View File

@ -72,7 +72,7 @@ module Vagrant
@home_path = opts[:home_path]
ui_class = opts[:ui_class] || UI::Silent
@ui = ui_class.new(self)
@ui = ui_class.new("vagrant")
@loaded = false
@lock_acquired = false

View File

@ -10,11 +10,11 @@ module Vagrant
# * `error`
# * `success`
class Interface
attr_accessor :env
attr_accessor :resource
def initialize(env)
@env = env
def initialize(resource)
@logger = Log4r::Logger.new("vagrant::ui::interface")
@resource = resource
end
[:warn, :error, :info, :success].each do |method|
@ -89,7 +89,7 @@ module Vagrant
# This is called by `say` to format the message for output.
def format_message(type, message, opts=nil)
opts ||= {}
message = "[#{env.resource}] #{message}" if opts[:prefix]
message = "[#{@resource}] #{message}" if opts[:prefix]
message
end
end

View File

@ -159,10 +159,22 @@ module Vagrant
def powered_off?; @vm.powered_off? end
def ui
return @_ui if defined?(@_ui)
@_ui = @env.ui.dup
@_ui.resource = @name
@_ui
end
protected
def run_action(name, options=nil)
env.action_runner.run(name, { :vm => self }.merge(options || {}))
options = {
:vm => self,
:ui => ui
}.merge(options || {})
env.action_runner.run(name, options)
end
end
end