suppress postgres meta-data sql in rails logs?

0 views
Skip to first unread message

Bryan

unread,
Apr 26, 2008, 11:04:12 PM4/26/08
to pdx...@googlegroups.com
Anyone know of an existing hack to suppress the annoying postgresql meta-data queries in Rails logs?  My development/test log files are cluttered with this junk (I'm guessing 80% of the log):
  SQL (0.001185)    SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
 FROM pg_attribute a LEFT JOIN pg_attrdef d
 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
 WHERE a.attrelid = 'people'::regclass
 AND a.attnum > 0 AND NOT a.attisdropped
 ORDER BY a.attnum

I'm sure I can hack something in AR or wherever, but I'm guessing someone else has done this already.  I didn't find anything in google though, but maybe I was searching for the wrong terms.

Thanks,
Bryan

Bryan

unread,
Apr 27, 2008, 12:19:00 AM4/27/08
to pdx...@googlegroups.com
I ended up just doing this:
module ActiveRecord
  module ConnectionAdapters # :nodoc:
    class AbstractAdapter
      def log_info(sql, name, runtime)
        if @logger && @logger.debug? && !sql.match(/relname/) && !sql.match(/attname/)
          name = "#{name.nil? ? "SQL" : name} (#{sprintf("%f", runtime)})"
          @logger.debug format_log_entry(name, sql.squeeze(' '))
        end
      end
    end
  end
end
Reply all
Reply to author
Forward
0 new messages