Resource prefixes in UI output work
This commit is contained in:
parent
40b9254d5a
commit
baba6af4ff
|
@ -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
|
||||
|
|
|
@ -10,11 +10,11 @@ module Vagrant
|
|||
# * `error`
|
||||
# * `success`
|
||||
class Interface
|
||||
attr_accessor :env
|
||||
attr_accessor :resource
|
||||
|
||||
def initialize(env)
|
||||
@env = env
|
||||
@logger = Log4r::Logger.new("vagrant::ui::interface")
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue