minor style and doc fixes. warning about logging performance issues.

This commit is contained in:
Kyle Banker 2011-01-31 15:51:39 -05:00
parent 8a7296599b
commit 9c83ca6b3e
3 changed files with 17 additions and 9 deletions

View File

@ -61,7 +61,8 @@ module Mongo
# on initialization. # on initialization.
# @option opts [Boolean] :slave_ok (false) Must be set to +true+ when connecting # @option opts [Boolean] :slave_ok (false) Must be set to +true+ when connecting
# to a single, slave node. # to a single, slave node.
# @option opts [Logger, #debug] :logger (nil) Logger instance to receive driver operation log. # @option opts [Logger, #debug] :logger (nil) A Logger instance for debugging driver ops. Note that
# logging negatively impacts performance; therefore, it should not be used for high-performance apps.
# @option opts [Integer] :pool_size (1) The maximum number of socket connections allowed per # @option opts [Integer] :pool_size (1) The maximum number of socket connections allowed per
# connection pool. Note: this setting is relevant only for multi-threaded applications. # connection pool. Note: this setting is relevant only for multi-threaded applications.
# @option opts [Float] :timeout (5.0) When all of the connections a pool are checked out, # @option opts [Float] :timeout (5.0) When all of the connections a pool are checked out,
@ -534,7 +535,9 @@ module Mongo
end end
end end
# execute the block and log the operation as described by name/payload # Execute the block and log the operation described by name
# and payload.
# TODO: Not sure if this should take a block.
def instrument(name, payload = {}, &blk) def instrument(name, payload = {}, &blk)
res = yield res = yield
log_operation(name, payload) log_operation(name, payload)
@ -574,6 +577,11 @@ module Mongo
@logger = opts[:logger] || nil @logger = opts[:logger] || nil
if @logger
@logger.debug("MongoDB logging. Please note that logging negatively impacts performance " +
"and should be disabled for high-performance production apps.")
end
should_connect = opts.fetch(:connect, true) should_connect = opts.fetch(:connect, true)
connect if should_connect connect if should_connect
end end