Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

We also need to ignore newlines in SQL when recording.

  • Loading branch information...
commit 10d85f7256ad3abe43cd190e00eea65913fab721 1 parent caccc8f
@threedaymonk authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/qtrace.rb
View
10 lib/qtrace.rb
@@ -5,18 +5,19 @@ class FakeException < StandardError; end
alias_method :__rails_standard_log, :log
def log(sql, name, &blk)
- if QTrace.match?(sql)
+ sql_without_newlines = sql.gsub(/\s*\n\s*/, ' ')
+ if QTrace.match?(sql_without_newlines)
begin
raise FakeException
rescue FakeException => e
- ([sql] + e.backtrace[1..-1]).each do |line|
+ ([sql_without_newlines] + e.backtrace[1..-1]).each do |line|
puts('** '+line) unless line =~ %r{/rails/|/lib/ruby/}
end
end
end
t0 = Time.now
ret = __rails_standard_log(sql, name, &blk)
- QTrace.record(sql, Time.now - t0)
+ QTrace.record(sql_without_newlines, Time.now - t0)
ret
end
end
@@ -69,8 +70,7 @@ def regexp
end
def match?(sql)
- sql_without_newlines = sql.gsub(/\s*\n\s*/, ' ')
- patterns.any? && sql_without_newlines.match(regexp)
+ patterns.any? && sql.match(regexp)
end
def show_statistics
Please sign in to comment.
Something went wrong with that request. Please try again.