Created
November 13, 2012 17:29
-
-
Save cmhobbs/4067164 to your computer and use it in GitHub Desktop.
fancy debug method (public)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEBUG = true | |
def debug(msg, obj = nil) | |
msg = ("== DEBUG: #{msg}") unless (msg.class != String) | |
$stderr.puts msg if DEBUG | |
$stderr.puts obj if (DEBUG && obj != nil) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):006:0> h = {:foo => "bar", :baz => "quux"} | |
=> {:foo=>"bar", :baz=>"quux"} | |
irb(main):007:0> debug "i'm a debug statement" | |
== DEBUG: i'm a debug statement | |
irb(main):008:0> debug "here's a hash", h | |
== DEBUG: here's a hash | |
{:foo=>"bar", :baz=>"quux"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
original: https://gist.github.com/2258db2eb615082ec1dd