From d65194d66ed62b0aaa5aa6591b52044a1a429644 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 2 Sep 2010 21:24:59 -0700 Subject: [PATCH] Only initialize a logger on the parent environment --- lib/vagrant/environment.rb | 1 + test/vagrant/environment_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 7b02ab2d3..c1197e839 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -158,6 +158,7 @@ module Vagrant # logger which should be used to log internals only. For outward # facing information, use {#ui}. def logger + return parent.logger if parent @logger ||= Util::ResourceLogger.new(resource, self) end diff --git a/test/vagrant/environment_test.rb b/test/vagrant/environment_test.rb index 785ffcf53..839fc2a8a 100644 --- a/test/vagrant/environment_test.rb +++ b/test/vagrant/environment_test.rb @@ -254,6 +254,15 @@ class EnvironmentTest < Test::Unit::TestCase assert_equal result, @env.logger assert_equal result, @env.logger end + + should "return the parent's local data if a parent exists" do + @env = mock_environment + @env.stubs(:parent).returns(mock_environment) + result = @env.parent.logger + + Vagrant::Util::ResourceLogger.expects(:new).never + assert_equal result, @env.logger + end end context "loading" do