dear monkists,
to make debugging easy, I would like to do any of the following to turn debugging on or off, specifically in a mod_perl deployed application;
- set a var as in $debug
- set a constant DEBUG, that is global for all packages
- set a function sub debug()
I note in 2001, that this was discussed before.
My questions are thus;
- whats the best way to do this in mod_perl(Apache2) these days?
- does there exist a PerlSetConstant or equiv directive?
- are there any overarching DEBUG harnesses (perhaps in CPAN) that are handy ?
thanks in advance
update
Thank you for the advice, I decided to go down the following route to get what I wanted; e.g. flexible logging, with assertions and DEBUG flag... with a roughly accurate timing mechanism.
use Benchmark::Stopwatch;
use Log::Log4perl;
use Carp::Assert;
*ADEBUG = *DEBUG;
undef *DEBUG;
the DEBUG constant is defined by both Log::Log4perl and Carp::Assert ... so I had to redefine it.
With this setup, I can reuse Carp::Assert PERL_NDEBUG env variable for controlling execution of DEBUG statements and assertions. This is easily set in either Apache using PerlSetEnv directive or setting/exporting environment variable on underlying OS
I also included benchmarking, which activates only if DEBUG is enabled
$stopwatch = Benchmark::Stopwatch->new->start if DEBUG;
update 2
I now find that Devel::NYTProf::Apache can completely replace this approach in mod_perl apps
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.