Skip to content

Instantly share code, notes, and snippets.

@belt
belt / query_trace.rb
Created August 10, 2011 16:33
QueryTrace... ported to rails3
require 'term/ansicolor'
# yeilds a stacktrace for each SQL query
# put this file in config/initializers
class QueryTrace < ActiveSupport::LogSubscriber
include Term::ANSIColor
attr_accessor :trace_queries
def sql(event) #:nodoc:
return unless QueryTrace.enabled? && logger.debug? && Rails.env.development?