Skip to content

Instantly share code, notes, and snippets.

@bluerabbit
Created January 8, 2020 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluerabbit/7f53cbca8a7864494907f82328305a38 to your computer and use it in GitHub Desktop.
Save bluerabbit/7f53cbca8a7864494907f82328305a38 to your computer and use it in GitHub Desktop.
ActiveRecord(mysql2 gem)でSQLのログを出すパッチ
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