Created
May 6, 2013 06:56
-
-
Save letronje/5523716 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
module ConnectionAdapters | |
class PostgreSQLAdapter | |
if defined?(Rails) | |
LOGGER_REGEXP = /^#{Rails.root}(?!\/vendor\/rails)/ | |
def query_with_extra_logging(*args) #:nodoc: | |
if ActiveRecord::Base.enable_extended_logging && Rails.logger && Rails.logger.level == Logger::DEBUG | |
sql = args.first | |
unless (sql =~ /(pg_get_constraintdef|pg_attribute|pg_class)/) | |
Rails.logger.debug | |
Rails.logger.debug(caller.select { |x| | |
ActiveRecord::Base.enable_really_extended_logging || x.match(LOGGER_REGEXP) | |
}.join("\n")) | |
end | |
end | |
query_without_extra_logging(*args) | |
end | |
alias_method_chain :query, :extra_logging |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment