Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better format for byebug (with colors)

Is there a way to get a better format of output with byebug? When I print objects the output is a little hard to read, would be better with colors similar to Awesome Print.

like image 712
Rich Avatar asked Dec 01 '15 23:12

Rich


3 Answers

There is no native option on byebug to format the output with colors, but there is a Gem you can use to colorize some of byebug output for ease of readability, which I think is what you are aiming here.

Please follow this link to see instructions on how to install byebug-color-printer Gem. https://github.com/ahmadsherif/byebug-color-printer

Or you could use pry. https://github.com/pry/pry :)

Let me know how this works for you. I hope it helps.

like image 175
Deivide Oliveira Avatar answered Oct 24 '22 10:10

Deivide Oliveira


debug.rb (aka binding.break)

Consider using a new Ruby debugging tool called debug.rb.

It supports syntax highlighting and many more out-of-the-box.

Also, it is worth mentioning that it is developed by the Ruby core team.

Just place binding.break anywhere in your codebase.

Here is an example:

binding.break example

Also, it is a default Rails debugger starting from version 7.

Notes:

  • Do not forget about require 'debug'
  • q # quit command

Sources:

  • debug.rb
  • Modify source code with binding.break (similar to binding.pry or binding.irb)
  • Rails 7 replaced byebug with ruby/debug
  • Depend on ruby/debug, replacing Byebug
like image 44
Marian13 Avatar answered Oct 24 '22 10:10

Marian13


If you add awesome_print to your project (via the Gemfile if you use bundler), then ap will be available to you inside byebug.

like image 1
Guy Argo Avatar answered Oct 24 '22 11:10

Guy Argo