diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-09-21 12:05:28 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-09-21 12:05:28 -0700 |
commit | 1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50 (patch) | |
tree | 36201d3efb5af8ae5ec1898fd6f3b8b366227819 /activerecord/lib | |
parent | e2d0b0ee61c5a8c2626abb5ac1029b48ec1965eb (diff) | |
parent | 4215e9ab936efca915ca998273d2fc0c46bb59b8 (diff) | |
download | rails-1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50.tar.gz rails-1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50.tar.bz2 rails-1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50.zip |
Merge commit 'jose/orchestra'
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index fab70f34b9..78c7a4b697 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -201,16 +201,12 @@ module ActiveRecord protected def log(sql, name) - if block_given? - result = nil - ms = Benchmark.ms { result = yield } - @runtime += ms - log_info(sql, name, ms) - result - else - log_info(sql, name, 0) - nil + event = ActiveSupport::Orchestra.instrument(:sql, :sql => sql, :name => name) do + yield if block_given? end + @runtime += event.duration + log_info(sql, name, event.duration) + event.result rescue Exception => e # Log message and raise exception. # Set last_verification to 0, so that connection gets verified @@ -221,10 +217,10 @@ module ActiveRecord raise translate_exception(e, message) end - def translate_exception(e, message) - # override in derived class - ActiveRecord::StatementInvalid.new(message) - end + def translate_exception(e, message) + # override in derived class + ActiveRecord::StatementInvalid.new(message) + end def format_log_entry(message, dump = nil) if ActiveRecord::Base.colorize_logging |