Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1059 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 06a6133f
*SVN*
* Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de]
* Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [skaes@web.de]
* Fixed bug in Base#hash method that would treat records with the same string-based id as different [Dave Thomas]
......
......@@ -687,16 +687,16 @@ def sanitize(object) #:nodoc:
def benchmark(title)
result = nil
bm = Benchmark.measure { result = silence { yield } }
logger.info "#{title} (#{sprintf("%f", bm.real)})"
logger.info "#{title} (#{sprintf("%f", bm.real)})" if logger
return result
end
# Silences the logger for the duration of the block.
def silence
result = nil
logger.level = Logger::ERROR
logger.level = Logger::ERROR if logger
result = yield
logger.level = Logger::DEBUG
logger.level = Logger::DEBUG if logger
return result
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册