tracer main class
Symbol table used for displaying trace information
Reference to singleton instance of Tracer
Used to filter unwanted trace output
Example which only outputs lines of code executed within the Kernel class:
Tracer.add_filter do |event, file, line, id, binding, klass, *rest| "Kernel" == klass.to_s end
# File tracer.rb, line 275 def Tracer.add_filter(p = proc) Single.add_filter(p) end
Disable tracing
# File tracer.rb, line 248 def Tracer.off Single.off end
Start tracing
Tracer.on # code to trace here Tracer.off
You can also pass a block:
Tracer.on { # trace everything in this block }
# File tracer.rb, line 237 def Tracer.on if block_given? Single.on{yield} else Single.on end end
Register an event handler p
which is called everytime a line
in file_name
is executed.
Example:
Tracer.set_get_line_procs("example.rb", lambda { |line| puts "line number executed is #{line}" })
# File tracer.rb, line 262 def Tracer.set_get_line_procs(file_name, p = proc) Single.set_get_line_procs(file_name, p) end
Commenting is here to help enhance the documentation. For example, sample code, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.