如何关闭Rails中的sqlite3'sqlite_master'登录? [英] How do I turn off the sqlite3 'sqlite_master' logging in rails?

查看:80
本文介绍了如何关闭Rails中的sqlite3'sqlite_master'登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的开发日志填满了

从sqlite_master中选择名称WHERE 类型=表",而不是名称= 'sqlite_sequence'

SELECT name FROM sqlite_master WHERE type = 'table' AND NOT name = 'sqlite_sequence'

我想在sqlite3中关闭sqlite_master查询,以便只看到有趣的查询.

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.

仅在Rails 2.3.8上进行了测试.

Tested only on Rails 2.3.8.

我在activerecord gem的SQLiteAdapter类中添加了一个log_info方法,该方法重写了AbstractAdapter中的相同方法.

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

因此,不会记录任何包含"sqlite_master"的sql语句.

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

这篇关于如何关闭Rails中的sqlite3'sqlite_master'登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆