Toffee¶ ↑
Candy for your “puts”-debugging!
Usage¶ ↑
Put the method call: “d” (almost) anywhere in your code to print out debug information:
['a', 'b', 'c'].d.first.d.upcase.d
will print out:
["a", "b", "c"] "a" "A"
“d” always returns self, so it will not interfere or do any harm.
Configure the output (optional)¶ ↑
Write to standard output (default):
Toffee.configure(STDOUT)
or
Toffee.configure(:stdout)
Write to any object that implements “:puts”:
Toffee.configure(IO.new(2, 'w'))
Write to any object that implements “:debug”:
Toffee.configure(Rails.logger)
Write to any object that implements the second parameter:
Toffee.configure(Rails.logger, :info)
Write to file using the shell command:
$ echo "my output here" > /tmp/foo.log Toffee.configure('/tmp/foo.log')
More options to use with Toffee.configure¶ ↑
-
:timestamp
-
Turn on timestamps with true, turn if off with nil or false; to use a custom timestamp format, pass a string with a Time.strftime kind of format
Copyright¶ ↑
Copyright © 2010 Christoph Petschnig. See LICENSE for details.
Inspiration and parts of the code taken from Jan Lelis (github.com/janlelis/zucker)