Last Updated: January 23, 2019
· taylorfausak

Colorize debug output

I found myself printing a bunch of debugging statements to the console and I couldn't tell where one line ended and the next began. I was using something like this:

pp thing

I modified that to colorize the output based on the thing's object ID, which is more or less random.

puts "\033[3#{thing.object_id % 8}m#{thing.inspect}\033[0m"