Created
January 8, 2020 02:48
-
-
Save bluerabbit/7f53cbca8a7864494907f82328305a38 to your computer and use it in GitHub Desktop.
ActiveRecord(mysql2 gem)でSQLのログを出すパッチ
This file contains hidden or 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 Mysql2 | |
class Client | |
orig_query = instance_method(:query) | |
define_method(:query) do |sql, options = {}| | |
Rails.logger.info("[#{Time.current}] SQL:[#{sql}]") | |
orig_query.bind(self).call(sql, options) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment