ããã¯ä½ï¼
Arproxyã使ãã¨ãActiveRecordãçºè¡ããSQLãDB Adapterã«ãã£ã¦å®è¡ãããç´åãããã¯ãããã¨ãã§ãã¾ããããã«ãã£ã¦ãã«ã¹ã¿ãã¤ãºããã¯ã¨ãªãã°ãåºåããããã©ãããã¯ã¨ãªãçºè¡ãããã®ãããã¬ã¼ã¹ããããããã¨ãã§ããããã«ãªãã¾ãã
Arproxyã§ã¯ãDB Adapterã®ããã¯å¦çã以ä¸ã®ããã«å®ç¾©ãã¾ããããã¯ã¯ã¨ãªãå®è¡ããããã³ã«ããã¯ãã¬ã¼ã¹ãåºåããä¾ã§ãã*1
class QueryTracer < Arproxy::Base def execute(sql, name=nil) Rails.logger.debug sql Rails.logger.debug caller(1).join("\n") super(sql, name) end end
ä¸è¨ã®ãããã·ã使ãå ´åã¯ãRailsã® config/initializers 以ä¸ã§ä»¥ä¸ã®ãããªåæåå¦çãæ¸ãã¾ãã
Arproxy.configure do |config| config.adapter = "mysql2" # database.yml ã§æå®ããDBã¢ããã¿ã®ååã§ã config.use QueryTracer end Arproxy.enable!
ä¸åº¦ãRackã®middlewareãuseããã®ã¨ä¼¼ãè¨æ³ã§ãã
ããã§ãActiveRecordã§SQLãå®è¡ããããã³ã«ããã®ã¯ã¨ãªã®ããã¯ãã¬ã¼ã¹ãåºåããã¾ãã
ãããã«
DBã®ããã¯ãç°¡åã«æ¸ããã®ã§ããªã«ãã¨å½¹ã«ç«ã¤ã¨æãã¾ãã
詳ããã¯ä»¥ä¸ã®URLãè¦ã¦ä¸ããã
https://github.com/cookpad/arproxy