diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-03-11 12:30:28 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-03-11 12:30:28 +0000 |
commit | be408bd4c6412cc2646731e0740dcefa4e0fc775 (patch) | |
tree | c57672d8b33fe129ddd84a3b0bfc668376f96e41 | |
parent | 9cc32a9ec8f69e810c0c65f3dae78f2b40e20aff (diff) | |
download | rails-be408bd4c6412cc2646731e0740dcefa4e0fc775.tar.gz rails-be408bd4c6412cc2646731e0740dcefa4e0fc775.tar.bz2 rails-be408bd4c6412cc2646731e0740dcefa4e0fc775.zip |
Fix @logger.debug? conditional considering @logger may be nil.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6375 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 11112106f7..fc29f11e15 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -23,7 +23,7 @@ module ActiveRecord class AbstractAdapter include Quoting, DatabaseStatements, SchemaStatements @@row_even = true - + def initialize(connection, logger = nil) #:nodoc: @connection, @logger = connection, logger @runtime = 0 @@ -41,7 +41,7 @@ module ActiveRecord def supports_migrations? false end - + # Does this adapter support using DISTINCT within COUNT? This is +true+ # for all adapters except sqlite. def supports_count_distinct? @@ -86,7 +86,7 @@ module ActiveRecord end # Lazily verify this connection, calling +active?+ only if it hasn't - # been called for +timeout+ seconds. + # been called for +timeout+ seconds. def verify!(timeout) now = Time.now.to_i if (now - @last_verification) > timeout @@ -94,24 +94,20 @@ module ActiveRecord @last_verification = now end end - + # Provides access to the underlying database connection. Useful for # when you need to call a proprietary method such as postgresql's lo_* # methods def raw_connection @connection end - + def log_info(sql, name, runtime) - return unless @logger or !@logger.debug? - - @logger.debug( - format_log_entry( - "#{name.nil? ? "SQL" : name} (#{sprintf("%f", runtime)})", - sql.gsub(/ +/, " ") - ) - ) - end + if @logger && @logger.debug? + name = "#{name.nil? ? "SQL" : name} (#{sprintf("%f", runtime)})" + @logger.debug format_log_entry(name, sql.squeeze(' ')) + end + end protected def log(sql, name) |