Merge pull request #64 from songbird/songbird-collection-logging
Allow logging from Collection using Connection logger.
This commit is contained in:
commit
2e48229a3b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue