method
    
    new
  
      v2_5_5 - 
      Show latest stable
 - 
    0 notes - 
    Class: TracePoint
    
  
  
- 1_8_6_287
 - 1_8_7_72
 - 1_8_7_330
 - 1_9_1_378
 - 1_9_2_180
 - 1_9_3_125
 - 1_9_3_392
 - 2_1_10 (0)
 - 2_2_9 (0)
 - 2_4_6 (0)
 - 2_5_5 (38)
 - 2_6_3 (0)
 - What's this?
 
new(*args)
  public
  Returns a new TracePoint object, not enabled by default.
Next, in order to activate the trace, you must use TracePoint#enable
trace = TracePoint.new(:call) do |tp| p [tp.lineno, tp.defined_class, tp.method_id, tp.event] end #=> #<TracePoint:disabled> trace.enable #=> false puts "Hello, TracePoint!" # ... # [48, IRB::Notifier::AbstractNotifier, :printf, :call] # ...
When you want to deactivate the trace, you must use TracePoint#disable
trace.disable
See TracePoint@Events for possible events and more information.
A block must be given, otherwise an ArgumentError is raised.
If the trace method isn’t included in the given events filter, a RuntimeError is raised.
TracePoint.trace(:line) do |tp| p tp.raised_exception end #=> RuntimeError: 'raised_exception' not supported by this event
If the trace method is called outside block, a RuntimeError is raised.
TracePoint.trace(:line) do |tp| $tp = tp end $tp.lineno #=> access from outside (RuntimeError)
Access from other threads is also forbidden.

  
  