Merge pull request #2713 from tmatilai/log_plugin_versions

core: log loaded plugin versions
This commit is contained in:
Mitchell Hashimoto 2013-12-28 12:49:00 -08:00
commit 5146bc2696
1 changed files with 8 additions and 2 deletions

View File

@ -186,8 +186,9 @@ module Vagrant
# #
# @param [String] name Name of the plugin to load. # @param [String] name Name of the plugin to load.
def self.require_plugin(name) def self.require_plugin(name)
if ENV["VAGRANT_NO_PLUGINS"]
logger = Log4r::Logger.new("vagrant::root") logger = Log4r::Logger.new("vagrant::root")
if ENV["VAGRANT_NO_PLUGINS"]
logger.warn("VAGRANT_NO_PLUGINS is set, not loading 3rd party plugin: #{name}") logger.warn("VAGRANT_NO_PLUGINS is set, not loading 3rd party plugin: #{name}")
return return
end end
@ -205,7 +206,6 @@ module Vagrant
rescue Exception => e rescue Exception => e
# Since this is a rare case, we create a one-time logger here # Since this is a rare case, we create a one-time logger here
# in order to output the error # in order to output the error
logger = Log4r::Logger.new("vagrant::root")
logger.error("Failed to load plugin: #{name}") logger.error("Failed to load plugin: #{name}")
logger.error(" -- Error: #{e.inspect}") logger.error(" -- Error: #{e.inspect}")
logger.error(" -- Backtrace:") logger.error(" -- Backtrace:")
@ -236,6 +236,12 @@ module Vagrant
raise Errors::PluginLoadFailed, raise Errors::PluginLoadFailed,
:plugin => name :plugin => name
end end
# Log plugin version
gem = Gem::Specification.find { |spec| spec.name == name }
version = gem ? gem.version : "<unknown>"
logger.info("Loaded plugin #{name}, version #{version}")
ensure ensure
$stderr = previous_stderr if previous_stderr $stderr = previous_stderr if previous_stderr
$stdout = previous_stdout if previous_stdout $stdout = previous_stdout if previous_stdout