Perl Monk, Perl Meditation | |
PerlMonks |
Re: How to get diagnostic information for a web app when nothing is written to the error logby wollmers (Scribe) |
on Oct 16, 2015 at 09:40 UTC ( [id://1145082]=note: print w/replies, xml ) | Need Help?? |
When I have such a problem in foreign code and cannot locate it easily (because the code is badly structured), I insert diagnostic messages. You can send them to client or to the error log of the webserver (print STDERR). So you maybe can debug, if this part of code is reached, how some variables are set. If you can still not locate, because the code is deeply nested (Spaghetti Code), then you can factor out subroutines for element groups. Each of the subroutines calls the subroutines for child content, and includes the child content between the opening and closing HTML tags.
Of course you could also attach HTML comments for BEGIN and END like in the above example. So you can see in the HTML source where the closing div comes from or which is missing. With the above small subroutines you can be sure, that they are properly closed. I use these often to repair bogus code. This method which I call "microtemplates" can be applied partially. And the code is fast.
In Section
Seekers of Perl Wisdom
|
|