Merge pull request #8041 from chrisroberts/ui/nicer-outputs

Logger and error outputs
This commit is contained in:
Chris Roberts 2016-11-28 07:59:49 -08:00 committed by GitHub
commit 3ec6290ad0
3 changed files with 25 additions and 4 deletions

View File

@ -264,6 +264,9 @@ if Vagrant.plugins_init?
Vagrant::Bundler.instance.init!(plugins)
rescue Exception => e
global_logger.error("Plugin initialization error - #{e.class}: #{e}")
e.backtrace.each do |backtrace_line|
global_logger.debug(backtrace_line)
end
raise Vagrant::Errors::PluginInitError, message: e.to_s
end
end
@ -330,6 +333,10 @@ if Vagrant.plugins_enabled?
::Bundler.require(:plugins)
end
rescue Exception => e
global_logger.error("Plugin loading error: #{e.class} - #{e}")
e.backtrace.each do |backtrace_line|
global_logger.debug(backtrace_line)
end
raise Vagrant::Errors::PluginLoadError, message: e.to_s
end
end

View File

@ -14,14 +14,22 @@ module VagrantPlugins
class RepairPlugins
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::plugins::plugincommand::repair")
end
def call(env)
env[:ui].info(I18n.t("vagrant.commands.plugin.repairing"))
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
Vagrant::Bundler.instance.init!(plugins, :repair)
env[:ui].info(I18n.t("vagrant.commands.plugin.repair_complete"))
begin
Vagrant::Bundler.instance.init!(plugins, :repair)
env[:ui].info(I18n.t("vagrant.commands.plugin.repair_complete"))
rescue Exception => e
@logger.error("Failed to repair user installed plugins: #{e.class} - #{e}")
e.backtrace.each do |backtrace_line|
@logger.debug(backtrace_line)
end
env[:ui].error(I18n.t("vagrant.commands.plugin.repair_failed", message: e.message))
end
# Continue
@app.call(env)
end

View File

@ -1647,7 +1647,13 @@ en:
repair_complete: |-
Installed plugins successfully repaired!
repair_failed: |-
Failed to automatically repair installed Vagrant plugins. Failure message:
Failed to automatically repair installed Vagrant plugins. To fix this
problem remove all user installed plugins and reinstall. Vagrant can
do this for you automatically by running the following command:
vagrant plugin expunge --reinstall
Failure message received during repair:
%{message}
snapshot: