Skip to content

Instantly share code, notes, and snippets.

@xaviershay
Created May 27, 2011 04:18
Show Gist options
  • Select an option

  • Save xaviershay/994632 to your computer and use it in GitHub Desktop.

Select an option

Save xaviershay/994632 to your computer and use it in GitHub Desktop.
Ghetto query tracing for DataMapper. Put it in an initializer.
class QueryTraceLogger
def initialize(logger)
@logger = logger
end
def method_missing(method_name, *args)
if method_name == :debug
if args.first =~ /SQL/
Rails.logger.debug ""
Rails.backtrace_cleaner.clean(caller).each do |line|
Rails.logger.debug line
end
end
end
@logger.send(method_name, *args)
end
end
DataMapper.logger = QueryTraceLogger.new(Rails.logger)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment