diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-17 01:23:41 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-17 01:23:41 +0000 |
commit | c00bf5f0c62f72f84629c6873791a591c02ae62c (patch) | |
tree | 1425ac9ed77fbc75a6ecf86e2b27b2838d28f2ec /activerecord | |
parent | 2d9e59b2b6dec7d6e98bd594cbd5295a4b6689ed (diff) | |
download | rails-c00bf5f0c62f72f84629c6873791a591c02ae62c.tar.gz rails-c00bf5f0c62f72f84629c6873791a591c02ae62c.tar.bz2 rails-c00bf5f0c62f72f84629c6873791a591c02ae62c.zip |
Fixed the verbosity of using the AR store
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@639 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 656258e49b..a79d75bba3 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -669,10 +669,17 @@ module ActiveRecord #:nodoc: # end def benchmark(title) result = nil + bm = Benchmark.measure { result = silence { yield } } + logger.info "#{title} (#{sprintf("%f", bm.real)})" + return result + end + + # Silences the logger for the duration of the block. + def silence + result = nil logger.level = Logger::ERROR - bm = Benchmark.measure { result = yield } + result = yield logger.level = Logger::DEBUG - logger.info "#{title} (#{sprintf("%f", bm.real)})" return result end |