Skip to content

🔫: Parse 'bullet' log files and converts them other format for simplified analysis and storage.

License

Notifications You must be signed in to change notification settings

okabe-yuya/bullet_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BulletParser

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.

Installation

Add this line to your application's Gemfile:

gem 'bullet_parser'

And then execute:

$ bundle

Usage

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')

Example

# 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">]

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/okabe-yuya/bullet_parser

About

🔫: Parse 'bullet' log files and converts them other format for simplified analysis and storage.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published