Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How to get diagnostic information for a web app when nothing is written to the error log

by wollmers (Scribe)
on Oct 16, 2015 at 09:40 UTC ( [id://1145082]=note: print w/replies, xml ) Need Help??


in reply to How to get diagnostic information for a web app when nothing is written to the error log

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.

sub invoice { my $invoice_data = shift; my $items_html = invoice_items($invoice_data->{items}); my $invoice_number = $invoice_data->{number}; my $html = <<HTML; <div class="invoice"> <div class="invoice_no">$invoice_number</div> <div class="invoice_items"> $items_html </div><!-- END invoice_items --> </div><!-- END invoice --> HTML return $html; }

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.

  • Comment on Re: How to get diagnostic information for a web app when nothing is written to the error log
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1145082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-25 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found