diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb | 3 | ||||
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 26 |
2 files changed, 3 insertions, 26 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb index 00c71090f3..020acbbe5a 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb @@ -75,7 +75,8 @@ module ActiveRecord def cache_sql(sql) result = if @query_cache.has_key?(sql) - log_info(sql, "CACHE", 0.0) + ActiveSupport::Notifications.instrument("active_record.sql", + :sql => sql, :name => "CACHE", :connection_id => self.object_id) @query_cache[sql] else @query_cache[sql] = yield diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 1b8d3f7a05..4a9cc09032 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -190,13 +190,6 @@ module ActiveRecord "active_record_#{open_transactions}" end - def log_info(sql, name, ms) - if @logger && @logger.debug? - name = '%s (%.1fms)' % [name, ms] - @logger.debug(format_log_entry(name, sql.squeeze(' '))) - end - end - protected def log(sql, name) name ||= "SQL" @@ -208,7 +201,7 @@ module ActiveRecord result rescue Exception => e message = "#{e.class.name}: #{e.message}: #{sql}" - log_info(message, name, 0) + @logger.debug message if @logger raise translate_exception(e, message) end @@ -217,23 +210,6 @@ module ActiveRecord ActiveRecord::StatementInvalid.new(message) end - def format_log_entry(message, dump = nil) - if ActiveRecord::Base.colorize_logging - if @@row_even - @@row_even = false - message_color, dump_color = "4;36;1", "0;1" - else - @@row_even = true - message_color, dump_color = "4;35;1", "0" - end - - log_entry = " \e[#{message_color}m#{message}\e[0m " - log_entry << "\e[#{dump_color}m%#{String === dump ? 's' : 'p'}\e[0m" % dump if dump - log_entry - else - "%s %s" % [message, dump] - end - end end end end |