Slide 46
Slide 46 text
Tracer (in standard library)
Outputs a source level execution trace
https://ruby-doc.org/stdlib-2.6.3/libdoc/tracer/rdoc/Tracer.html
"Tracer" outputs a source level execution trace.
Using with Kernel.#set_trace_func in Tracer.
log.txt
...
#1:/path_to_app/app/views/books/index.html.erb:1:ActionView::CompiledTemplates:-: <%= @books = [] %>
...
Tracer.add_filter do |event, file, line, id, binding, klass|
file == "/path_to_app/app/views/books/index.html.erb"
end
Tracer.on
Filtering unwanted outputs
If we need source code, use File.open method in the filter.
(same as TracePoint)
⬆ Executed code
⬆ Source file infomation
⬅ Write this code
to the Rails app
⬇ and get log.txt file