Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
TracePoint.trace
(*::_ToSym events) { (instance tp) -> void } -> instance
TracePoint.trace(*events) { |tp| block } → obj
trace_point.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/trace_point.rb, line 134
def self.trace(*events)
Primitive.attr! :use_block
Primitive.tracepoint_trace_s(events)
end
A convenience method for TracePoint.new that activates the trace automatically.
Example
trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] } #=> #<TracePoint:enabled> trace.enabled? #=> true