How do I turn off the sqlite3 'sqlite_master' logging in rails?
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.
精彩评论