diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index e77cb17dc..cb6dc49ff 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -4,6 +4,7 @@ module Vagrant attr_reader :env attr_reader :system + attr_reader :logger attr_reader :name attr_accessor :vm @@ -42,6 +43,8 @@ module Vagrant # Load the associated system. load_system! end + + @logger = ResourceLogger.new(@name, @env) end # Loads the system associated with the VM. The system class is diff --git a/test/vagrant/vm_test.rb b/test/vagrant/vm_test.rb index 4e3a27e23..3aee41e00 100644 --- a/test/vagrant/vm_test.rb +++ b/test/vagrant/vm_test.rb @@ -37,7 +37,8 @@ class VMTest < Test::Unit::TestCase context "vagrant VM instance" do setup do - @vm = Vagrant::VM.new(:env => @env, :vm => @mock_vm) + @vm_name = "foo" + @vm = Vagrant::VM.new(:env => @env, :vm => @mock_vm, :vm_name => @vm_name) @mock_vm.stubs(:uuid).returns("foo") end @@ -53,6 +54,16 @@ class VMTest < Test::Unit::TestCase end end + context "the logger" do + should "create a logger for the proper environment" do + logger = @vm.logger + assert logger + assert logger.is_a?(Vagrant::ResourceLogger) + assert_equal @vm.env, logger.env + assert_equal @vm_name, logger.resource + end + end + context "accessing the SSH object" do setup do # Reset this to nil to force the reload