Permalink
Browse files

Adding Rails integration for toggling tracing.

Users can send a SIGQUIT signal (CTRL-\) to toggle tracing on and off.
A message will be printed to STDOUT indicating the status at startup.
Messages will also be printed when tracing is toggled.
  • Loading branch information...
1 parent d91e74f commit 8dee616ce6d23e2048ac4bb159d78bdcb9effb75 @dougbarth dougbarth committed with ffmike Feb 15, 2010
Showing with 17 additions and 1 deletion.
  1. +15 −0 init.rb
  2. +1 −1 query_trace.gemspec
  3. +1 −0 rails/init.rb
View
@@ -1 +1,16 @@
require 'query_trace'
+
+def status
+ QueryTrace.enabled? ? "enabled" : "disabled"
+end
+
+puts "=> QueryTrace #{status}; CTRL-\\ to toggle"
+
+trap("QUIT") do
+ # Sending 2 backspace characters removes the ^\ that is
+ # printed to the console.
+ rm_noise = "\b\b"
+
+ QueryTrace.toggle!
+ puts "#{rm_noise}=> QueryTrace #{status}"
+end
View
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.description = %q{With query_trace enabled, the Rails logs will contain a partial stack trace for every executed SQL statement, making it easier to find where they are generated in your code.}
s.email = %q{nathaniel@terralien.com}
s.extra_rdoc_files = ["README", "MIT-LICENSE"]
- s.files = ["MIT-LICENSE", "README", "Rakefile", "lib/query_trace.rb"]
+ s.files = ["MIT-LICENSE", "README", "Rakefile", "lib/query_trace.rb", "rails/init.rb"]
s.has_rdoc = true
s.homepage = %q{http://github.com/ffmike/query_trace/tree/master}
s.require_paths = ["lib"]
View

0 comments on commit 8dee616

Please sign in to comment.