Search code examples
rubydebuggingerlangruby-debugdbg

Ruby debug output - switch on/off easily


When I write draft and experimental code in Erlang I usually use this:

%%% Switch debugging output on/off:
-define(DBG(Str, Args), ok).
%-define(DBG(Str, Args), io:format(Str, Args)).

Commenting out just one line of code switches the debugging output to the console on and off.

?DBG("DEBUG: The function started ~n", [])

Thus I can use commenting in the code heavily.

Does something similar exist in Ruby?


Solution

  • Ruby Learning's section on logging might be helpful.