14

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.

Rich
  • 5,603
  • 9
  • 39
  • 61

4 Answers4

5

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.

Deivide Oliveira
  • 489
  • 5
  • 10
  • 3
    byebug-color-printer won't work unless you want to use a very old version of byebug: https://github.com/ahmadsherif/byebug-color-printer/blob/master/byebug-color-printer.gemspec#L21 – Gerry Aug 27 '16 at 07:30
3

I am using a hack for byebug syntax highlighting from this gist for more than a year now.

It is not perfect, but it does its job well.

Here is an example:

enter image description here

Note: It works for byebug v10.0.0 and higher.

Sources:

Marian13
  • 7,740
  • 2
  • 47
  • 51
1

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

Guy Argo
  • 397
  • 4
  • 10
1

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:

Marian13
  • 7,740
  • 2
  • 47
  • 51