The tracer gem provides helpful tracing utilities to help users observe their program's runtime behaviour.
The currently supported tracers are:
It also comes with experimental IRB integration to allow quick access from REPL.
Installation
$ bundle add tracer --group=development,test
Or directly add it to your Gemfile
group :development, :test do gem "tracer" end
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install tracer
Usage
Tracer.trace(object) { ... } # trace object's activities in the given block Tracer.trace_call { ... } # trace method calls in the given block Tracer.trace_exception { ... } # trace exceptions in the given block
Example
"require "tracer"
obj = Object.new
def obj.foo
100
end
def bar(obj)
obj.foo
end
Tracer.trace(obj) { bar(obj) }
#depth:1 #