Ruby 2.0: TracePoint
Ruby 2.0 deprecates Kernel#set_trace_func
in favor of the TracePoint class which has a nice object-oriented API. For example, tracing all C-calls can be as easy as
trace = TracePoint.trace(:c_call) { |tp| [tp.lineno, tp.event] }
which is a convenient shortcut for
trace = TracePoint.new(:c_call) do |tp|
p [tp.lineno, tp.event]
end
trace.enable
Written by Michael Kohl
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#