Only initialize a logger on the parent environment

This commit is contained in:
Mitchell Hashimoto 2010-09-02 21:24:59 -07:00
parent 32aa5ef4d1
commit d65194d66e
2 changed files with 10 additions and 0 deletions

View File

@ -158,6 +158,7 @@ module Vagrant
# logger which should be used to log internals only. For outward # logger which should be used to log internals only. For outward
# facing information, use {#ui}. # facing information, use {#ui}.
def logger def logger
return parent.logger if parent
@logger ||= Util::ResourceLogger.new(resource, self) @logger ||= Util::ResourceLogger.new(resource, self)
end end

View File

@ -254,6 +254,15 @@ class EnvironmentTest < Test::Unit::TestCase
assert_equal result, @env.logger assert_equal result, @env.logger
assert_equal result, @env.logger assert_equal result, @env.logger
end 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 end
context "loading" do context "loading" do