Trace ruby code
ruby 2
Add this line to your application's Gemfile:
gem 'source_route'
And then execute:
$ bundle
Or install it yourself as:
$ gem install source_route
SourceRoute.trace(output_format: :console, event: :c_call) { 'abc'.upcase }
SourceRoute.trace(defined_class: 'ActiveRecord::Attribute', output_format: :html) { User.new }
It will generate a html file, open it and you can get the trace of User.new
The intereting part is when you run the above command again(in same console), you will get a different trace file.
SourceRoute.enable do
method_id :wanted_method_name
full_feature
filename 'tmp/capture_wanted.html'
end
# Following is your code
....
....
....
# add it after your tracked code, it output the trace into a html file
SourceRoute.output_html
Same as the previous example, you will get a html file showing the code trace.
SourceRoute.enable do
defined_class :wanted_class_name
output_format :console
end
.... # here is your code
It will output the trace when you run the application.
see more usage in examples. see full usage in examples/study_callback.rb
Help me read source code and solve problem directly.
$ bundle install
$ rake
- Fork it ( https://github.com/raykin/source_route/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
add syntax to monitor when obj was passed into method
animation when node hide
use concurrent-ruby to speed up
call and return event combined together is no useful. So traces data structure need changed. Dynamic indent when new child level comes.
global disable some class from monitor
Add debug option to provide more verbose messages of what has happened
if instance val contains symbol as value, the json output will be string. It could be confused others.
Open File directly from browser(chrome) by plugin? Maybe check out how better error implement this