mirror of
https://github.com/github/rails.git
synced 2026-01-23 21:38:14 -05:00
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
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*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 @@ module ActiveRecord #: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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user