diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index be367e52c0..2c60938bda 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added use_silence parameter to ActiveRecord::Base.benchmark that can be passed false to include all logging statements during the benchmark block + * Make sure the schema_info table is created before querying the current version #1903 * Fixtures ignore table name prefix and suffix #1987 [Jakob S] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 6180f45fed..a6ce28685c 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -714,11 +714,17 @@ module ActiveRecord #:nodoc: # project.create_manager("name" => "David") # project.milestones << Milestone.find(:all) # end - def benchmark(title) - result = nil - seconds = Benchmark.realtime { result = silence { yield } } - logger.info "#{title} (#{sprintf("%f", seconds)})" if logger - return result + # + # The loggings of the multiple statements is turned off unless <tt>use_silence</tt> is set to false. + def benchmark(title, use_silence = true) + if logger + result = nil + seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield } + logger.info "#{title} (#{sprintf("%f", seconds)})" + result + else + yield + end end # Silences the logger for the duration of the block. |