If it helps anyone, I wrote a shortcut for set_trace_func, so next time
you want to just add a line before and after some function you are
trying to debug you can have Ruby temporarily output every line, method,
etc. executed. Also, it lets you define the format, use other loggers,
etc. via a proc/lambda define, since you might not like the default
format. Apologize for posting here if it wouldn't help- maybe you are
using a real debugger.
Example:
In Gemfile add:
gem 'autolog'
Around some part of code add this before:
Autolog.methods
and this after:
Autolog.off
Hope it helps someone who needs a quick tool periodically without all
the time sink of profiling or setting a breakpoint and debugging in a
slow IDE.
On Oct 17, 2012, at 11:35 , Gary Weaver <lists@ruby-forum.com> wrote:
If it helps anyone, I wrote a shortcut for set_trace_func, so next time
you want to just add a line before and after some function you are
trying to debug you can have Ruby temporarily output every line, method,
etc. executed. Also, it lets you define the format, use other loggers,
etc. via a proc/lambda define, since you might not like the default
format. Apologize for posting here if it wouldn't help- maybe you are
using a real debugger.
Example:
In Gemfile add:
gem 'autolog'
Around some part of code add this before:
Autolog.methods
and this after:
Autolog.off
Hope it helps someone who needs a quick tool periodically without all
the time sink of profiling or setting a breakpoint and debugging in a
slow IDE.
##
# Start tracing
#
# === Example
#
# Tracer.on
# # code to trace here
# Tracer.off
#
# You can also pass a block:
#
# Tracer.on {
# # trace everything in this block
# }
##
# Start tracing
#
# === Example
#
# Tracer.on
# # code to trace here
# Tracer.off
#
# You can also pass a block:
#
# Tracer.on {
# # trace everything in this block
# }
It is basically like an event-specific version of Tracer.