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]
|
@home_path = opts[:home_path]
|
||||||
|
|
||||||
ui_class = opts[:ui_class] || UI::Silent
|
ui_class = opts[:ui_class] || UI::Silent
|
||||||
@ui = ui_class.new(self)
|
@ui = ui_class.new("vagrant")
|
||||||
|
|
||||||
@loaded = false
|
@loaded = false
|
||||||
@lock_acquired = false
|
@lock_acquired = false
|
||||||
|
|
|
@ -10,11 +10,11 @@ module Vagrant
|
||||||
# * `error`
|
# * `error`
|
||||||
# * `success`
|
# * `success`
|
||||||
class Interface
|
class Interface
|
||||||
attr_accessor :env
|
attr_accessor :resource
|
||||||
|
|
||||||
def initialize(env)
|
def initialize(resource)
|
||||||
@env = env
|
|
||||||
@logger = Log4r::Logger.new("vagrant::ui::interface")
|
@logger = Log4r::Logger.new("vagrant::ui::interface")
|
||||||
|
@resource = resource
|
||||||
end
|
end
|
||||||
|
|
||||||
[:warn, :error, :info, :success].each do |method|
|
[:warn, :error, :info, :success].each do |method|
|
||||||
|
@ -89,7 +89,7 @@ module Vagrant
|
||||||
# This is called by `say` to format the message for output.
|
# This is called by `say` to format the message for output.
|
||||||
def format_message(type, message, opts=nil)
|
def format_message(type, message, opts=nil)
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
message = "[#{env.resource}] #{message}" if opts[:prefix]
|
message = "[#{@resource}] #{message}" if opts[:prefix]
|
||||||
message
|
message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -159,10 +159,22 @@ module Vagrant
|
||||||
|
|
||||||
def powered_off?; @vm.powered_off? end
|
def powered_off?; @vm.powered_off? end
|
||||||
|
|
||||||
|
def ui
|
||||||
|
return @_ui if defined?(@_ui)
|
||||||
|
@_ui = @env.ui.dup
|
||||||
|
@_ui.resource = @name
|
||||||
|
@_ui
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def run_action(name, options=nil)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue