Permalink
Browse files

Fixed Base.silence/benchmark to only log if a logger has been configu…

…red #986 [skaes@web.de]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1059 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 06a6133 commit aec31cd09f12fcda128582ef5bfbe25bb87db644 @dhh dhh committed Apr 2, 2005
Showing with 5 additions and 3 deletions.
  1. +2 −0 activerecord/CHANGELOG
  2. +3 −3 activerecord/lib/active_record/base.rb
View
2 activerecord/CHANGELOG
@@ -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]
View
6 activerecord/lib/active_record/base.rb
@@ -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

0 comments on commit aec31cd

Please sign in to comment.