The bullet is a gem designed to parse and tokenize the output .log files generated by it.
Based on my experience, I often review the contents of the bullet.log file produced by Bullet in order to validate instances of the "N+1 problem".
As parsing and identifying duplicate occurrences within the typical .log format can be challenging, I created this gem to facilitate conversion into a customizable format.
Add this line to your application's Gemfile:
gem 'bullet_parser'
And then execute:
$ bundle
Parse "bullet.log" file to tokens
# Please specify the path of the .log file in the argument
tokens = BulletParser.tokens('bullet.log')
Save parsed tokens as File(:csv)
tokens = BulletParser.tokens('bullet.log')
BulletParser.save(tokens, extension: :csv, filename: 'bullet_log.csv')
# tokens
[#<struct BulletParser::Tokenizer::Token
detected_at="2023-08-15 15:20:31",
log_level="WARN",
detected_user="okabe",
http_method="GET",
end_point="/api/v1/products/tags",
problem="USE eager loading detected\n Product => [:product_tags]\n Add to your query: .includes([:product_tags])\n",
root_line=" /Users/okabe/ruby/app/product_tags_controller.rb:18:in `map'\n",
callstack=
" /Users/okabe/ruby/app/product_tags_controller.rb:18:in `map'\n /Users/okabe/ruby/app/product_tags_controller.rb:18:in `block in <class:ProductTagsCotroller>'\n /Users/okabe/ruby/spec/requests/products/tags_spec.rb:30:in `block (3 levels) in <main>'\n">]
Bug reports and pull requests are welcome on GitHub at https://github.com/okabe-yuya/bullet_parser