Summary

Spit variables out to your log in a noticeable color. It adds a sensible label automatically.

Usage Examples

You use it by doing something like this:

Spit 

And it puts something like this in the log output (but with color):

account: <#Account @name="Steve">

To show the source of the line (filename, method, and line number) do something like this:

Spit.s 

And it puts something like this in the log output (but with color):

foo_controller.index(38) account: <#Account @name="Steve">

The Point

So you don’t have to keep typing things like this over and over while developing / debugging:

print "foo: #{foo}"

It’s intended to make it easier during development to print out values of variables and have them stand out in the log… pretty simple concept. There might be something out there like it - I didn’t look around very much.

How it works

The only tricky thing about spit is how it creates the label. Under the covers it uses caller() to get the file and line, and then goes and grabs the label from the actual source file. This isn’t super-efficient, but will likely be almost intstantaneous unless you print out a rather large number of variables at once.

Future plans

Support for multiple variables, like: Spit(account, user)

Support for choosing a color, like: Spit.red account

Copyright © 2011 trogdoro. See LICENSE.txt for further details.