Diagnostic printf

A better basic debugging tool.

The crude "lets drop a print statement in" approach keeps being useful even with advanced dynamic languages. Here's a (slightly) improved version for ruby that pretty prints any number of passed objects and (importantly) where the print call was made from:

def dbg (*args)
   print("dbg: #{caller()[0]}: ")
   args.each { |a|
      print "* #{a.inspect} "
   }
end

# Examples:
dbg(1, 2, 3, 4)
# Returns:
# DEBUG: /home/f0/paul/dbg.rb:11:
# * 1
# * 2
# * 3
# * 4

dbg(1, 2, 3, :abc => 4)
# DEBUG: /home/f0/paul/dbg.rb:13:
# * 1
# * 2
# * 3
# * {:abc=>4}