开发者

How do I turn off the sqlite3 'sqlite_master' logging in rails?

开发者 https://www.devze.com 2023-01-12 05:34 出处:网络
My development log fills up with SELECT nameFROM sqlite_masterWHERE 开发者_StackOverflow中文版type = \'table\' AND NOT name =

My development log fills up with

SELECT name FROM sqlite_master WHERE 开发者_StackOverflow中文版type = 'table' AND NOT name = 'sqlite_sequence'

I'd like to turn off the sqlite_master queries in sqlite3, so that I only see the interesting queries.


Here's how I fixed it. Perhaps there are better options.

Tested only on Rails 2.3.8.

I added a log_info method to the SQLiteAdapter class in the activerecord gem, which overrides the same method in AbstractAdapter.

      def log_info(sql, name, ms)
        unless sql.match(/sqlite_master/)
          if @logger && @logger.debug?
            name = '%s (%.1fms)' % [name || 'SQL', ms]
            @logger.debug(format_log_entry(name, sql.squeeze(' ')))
          end
        end
      end

so, any sql statement that contains 'sqlite_master' is not logged.

0

精彩评论

暂无评论...
验证码 换一张
取 消