From c1239e6509d27f88db2fc59189fd9a95333283e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 11 Jan 2010 15:14:52 +0100 Subject: Send the connection in AR notifications to avoid checking out new connections in threads just for logging purposes. --- .../lib/active_record/connection_adapters/abstract_adapter.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 5eedf448a4..1ad54e7584 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -193,15 +193,17 @@ module ActiveRecord def log_info(sql, name, ms) if @logger && @logger.debug? - name = '%s (%.1fms)' % [name || 'SQL', ms] + name = '%s (%.1fms)' % [name, ms] @logger.debug(format_log_entry(name, sql.squeeze(' '))) end end protected def log(sql, name) + name ||= "SQL" result = nil - ActiveSupport::Notifications.instrument("active_record.sql", :sql => sql, :name => name) do + ActiveSupport::Notifications.instrument("active_record.sql", + :sql => sql, :name => name, :connection => self) do @runtime += Benchmark.ms { result = yield } end result -- cgit v1.2.3