When you just went through a long debug-fest and infested your code with dozens of debug messages, it can be hard to find all those calls to puts
and p
. This note describes a hack that lets you trace those messages in your code.
Let's say you want to get rid of a console message "foobar". Copy the Undebug
class below to config/initializers.rb
. In the same initializer, type a line:
Undebug.trace_message('foobar')
Now run tests or whatever you need to do to to trigger that message. The console output should look like this:
Message tracing is active and slowing down the application! Disable me in /home/henning/projects/notes/config/initializers/undebug.rb:34.
foobar
Printed 'foobar' at /home/henning/projects/notes/features/step_definitions/web_steps.rb:280:in `puts'
When you're done, remember to remove that call to Undebug.trace_message
because it will slow down your application.
Posted by Henning Koch to makandra dev (2010-11-26 14:12)