Ruby -dn; levels for $DEBUG

I would find it convenient if:
    ruby -d foo.rb
set $DEBUG to true, while
   ruby -d1 foo.rb
set $DEBUG to 1
   ruby -d3 foo.rb
set $DEBUG to 3, and possibly even
   ruby -dALL foo.rb
set $DEBUG to "ALL". (I'm willing to give up that last, though.)

This would break any existing code that did something silly like:
    if $DEBUG == true
instead of
   if $DEBUG
but would provide the ability to set verbosity level for debugging.

In debugging JavaScript in HTML, I wrote my own DebugOut function which took a string and a verbosity level, and by changing one numeric at the top of the file could easily see more or less verbose traces of the code execution. It's a poor substitute for a debugging IDE, but at the same time quite helpful.

What do people think?

i just do this

   ~ > DEBUG=2 ruby a.rb

and in a.rb

   $DEBUG = Integer(ENV['DEBUG']) rescue true

hth.

-a

···

On Thu, 30 Jun 2005, Gavin Kistner wrote:

I would find it convenient if:
  ruby -d foo.rb
set $DEBUG to true, while
ruby -d1 foo.rb
set $DEBUG to 1
ruby -d3 foo.rb
set $DEBUG to 3, and possibly even
ruby -dALL foo.rb
set $DEBUG to "ALL". (I'm willing to give up that last, though.)

This would break any existing code that did something silly like:
  if $DEBUG == true
instead of
if $DEBUG
but would provide the ability to set verbosity level for debugging.

In debugging JavaScript in HTML, I wrote my own DebugOut function which took a string and a verbosity level, and by changing one numeric at the top of the file could easily see more or less verbose traces of the code execution. It's a poor substitute for a debugging IDE, but at the same time quite helpful.

What do people think?

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
My religion is very simple. My religion is kindness.
--Tenzin Gyatso

===============================================================================