mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
9cc32a9ec8
commit
be408bd4c6
1 changed files with 10 additions and 14 deletions
|
@ -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
|
||||
def log_info(sql, name, runtime)
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue