Merge pull request #64 from songbird/songbird-collection-logging

Allow logging from Collection using Connection logger.
This commit is contained in:
Kyle Banker 2011-11-28 10:19:10 -08:00
commit 2e48229a3b
2 changed files with 11 additions and 0 deletions

View File

@ -86,6 +86,7 @@ module Mongo
@db, @name = db, name
@connection = @db.connection
@logger = @connection.logger
@cache_time = @db.cache_time
@cache = Hash.new(0)
unless pk_factory

View File

@ -125,5 +125,15 @@ class CollectionTest < Test::Unit::TestCase
@coll.ensure_index [["x", Mongo::DESCENDING], ["y", Mongo::DESCENDING]]
end
should "use the connection's logger" do
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @conn['testing']
@coll = @db.collection('books')
@logger.expects(:warn).with do |msg|
msg == "MONGODB [WARNING] test warning"
end
@coll.log(:warn, "test warning")
end
end
end