aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/abstract_adapter.rb22
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