Subject: | Runtime switching |
I understand that a major selling point of Debug::Show is that when turned off, it is turned off at compile time, so has little run time overhead.
Nonetheless it can often be useful to turn on debug printing at run time. Is there scope for adding a mode where printing is controlled by a global variable?
use Debug::Show qw(debug=conditional);
$Debug::Show::On = 1;
debug('hello'); # prints
$Debug::Show::On = 0;
debug('goodbye'); # runs, but does not print
That would also allow things like
{
local $Debug::Show::On = 1;
# do some stuff with printing turned on
}
$Debug::Show::On = 1 if $opt_trace;
Later, the programmer would be able to change debug=conditional to debug=hide to have all the calls compiled out. But debug=conditional is a useful setting for non-performance-critical code where you want flexibility to start producing debug output (perhaps even in an already-running process).