diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 73b609962..c81c2adfd 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -1,3 +1,5 @@ +require 'log4r' + require 'vagrant/action/builder' require 'vagrant/action/builtin' @@ -93,6 +95,7 @@ module Vagrant # @param [Environment] env def initialize(env) @env = env + @logger = Log4r::Logger.new("vagrant::action") end # Runs the given callable object in the context of the environment. @@ -129,7 +132,7 @@ module Vagrant end # We place a process lock around every action that is called - env.logger.info "Running action: #{callable_id}" + @logger.info("Running action: #{callable_id}") env.lock do Busy.busy(int_callback) { callable.call(action_environment) } end diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 6bbb8cfc6..a08645688 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -1,3 +1,4 @@ +require 'log4r' require 'net/ssh' require 'net/scp' @@ -19,6 +20,7 @@ module Vagrant def initialize(environment) @env = environment + @logger = Log4r::Logger.new("vagrant::ssh") end # Connects to the environment's virtual machine, replacing the ruby @@ -53,7 +55,7 @@ module Vagrant end command = "ssh #{command_options.join(" ")} #{options[:username]}@#{options[:host]}".strip - env.logger.info("ssh") { "Invoking SSH: #{command}" } + @logger.info("Invoking SSH: #{command}") safe_exec(command) end @@ -68,7 +70,7 @@ module Vagrant opts[:forward_agent] = true if env.config.ssh.forward_agent opts[:port] ||= port - env.logger.info("ssh") { "Connecting to SSH: #{env.config.ssh.host} #{opts[:port]}" } + @logger.info("Connecting to SSH: #{env.config.ssh.host} #{opts[:port]}") # The exceptions which are acceptable to retry on during # attempts to connect to SSH @@ -137,12 +139,12 @@ module Vagrant # Windows systems don't have this issue return if Util::Platform.windows? - env.logger.info("ssh") { "Checking key permissions: #{key_path}" } + @logger.info("Checking key permissions: #{key_path}") stat = File.stat(key_path) if stat.owned? && file_perms(key_path) != "600" - env.logger.info("ssh") { "Attempting to correct key permissions to 0600" } + @logger.info("Attempting to correct key permissions to 0600") File.chmod(0600, key_path) raise Errors::SSHKeyBadPermissions, :key_path => key_path if file_perms(key_path) != "600" diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index 867564802..cb0b866be 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -1,3 +1,5 @@ +require 'log4r' + module Vagrant class VM include Vagrant::Util @@ -26,6 +28,7 @@ module Vagrant @vm = opts[:vm] @name = opts[:name] + @logger = Log4r::Logger.new("vagrant::vm") if !opts[:env].nil? # We have an environment, so we create a new child environment @@ -51,7 +54,7 @@ module Vagrant # **This method should never be called manually.** def load_system!(system=nil) system ||= env.config.vm.system - env.logger.info("vm: #{name}") { "Loading system: #{system}" } + @logger.info("Loading system: #{system}") if system.is_a?(Class) raise Errors::VMSystemError, :_key => :invalid_class, :system => system.to_s if !(system <= Systems::Base)