diff options
author | José Valim <jose.valim@gmail.com> | 2009-12-30 13:07:48 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-12-30 13:07:48 +0100 |
commit | 4ecdf24bdedfdd1cca1f079259ff2490e2074067 (patch) | |
tree | b31c55a662121d9da270cc47b001b2296f90eedf /activerecord/lib/active_record/connection_adapters | |
parent | 97204fc0bc52af8fb6714e6f9fcd414567e0fc1a (diff) | |
download | rails-4ecdf24bdedfdd1cca1f079259ff2490e2074067.tar.gz rails-4ecdf24bdedfdd1cca1f079259ff2490e2074067.tar.bz2 rails-4ecdf24bdedfdd1cca1f079259ff2490e2074067.zip |
Kick AR logging back to life and move ControllerRuntime inside ActiveRecord::Rails.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 8fae26b790..d09aa3c4d2 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -1,6 +1,7 @@ require 'date' require 'bigdecimal' require 'bigdecimal/util' +require 'active_support/core_ext/benchmark' # TODO: Autoload these files require 'active_record/connection_adapters/abstract/schema_definitions' @@ -191,7 +192,6 @@ module ActiveRecord end def log_info(sql, name, ms) - @runtime += ms if @logger && @logger.debug? name = '%s (%.1fms)' % [name || 'SQL', ms] @logger.debug(format_log_entry(name, sql.squeeze(' '))) @@ -199,8 +199,12 @@ module ActiveRecord end protected - def log(sql, name, &block) - ActiveSupport::Notifications.instrument(:sql, :sql => sql, :name => name, &block) + def log(sql, name) + result = nil + ActiveSupport::Notifications.instrument(:sql, :sql => sql, :name => name) do + @runtime += Benchmark.ms { result = yield } + end + result rescue Exception => e # Log message and raise exception. # Set last_verification to 0, so that connection gets verified |