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