(You are Anonymous)

Debugging Tips

Here are some tips to help with debugging your CGI::Applications.

Thilo Phlanz magic debugging language.

I have for my own use developed a few tools and methods that I incorporated into all my CGI::App subclasses.

First of all, my CGI::Apps allow me to toggle the display of debugging information right in the browser.

This is much more convenient than having to scan the server logs. This is activated by adding a special language "db-ug" to the browser's accepted languages.

How to change your language varies by browser in Mozilla it's under Preferences: Navigator: Languages.

The CGI::App is checking against a list of configured IP addresses and/or login IDs if it honors this request (not everyone can get this debugging info).

The info that is displayed consists of the output of CGI::App::dump_html plus a log of timestamped messages created throughout a program run. The output is automatically appended to the normal output created by CGI::App.

The messages are created by calling methods in a singleton class that collects and timestamps them. The timestamping is good to see performance issues. There are three log levels (inform, warn, error). You can pass references to these methods, they will be Data::Dumper'ed, so you can quickly examine complex structures. I am also using a custom SIGWARN handler to capture all Perl warnings in my debug log. My CGI::App subclasses and its service modules automatically create messages for events like authenticating users, loading templates, connecting to the database or preparing statements. It also displays the headers it sends (as for cookies) If the application dies, the error is caught and added to the debug log before exiting. When my aplication redirects to other URLS, this redirection is intercepted during debug mode, so you can see what is going on.

If other people are interested in trying this module, I could refactor it to strip it of out company-internal stuff and release it here.

Thilo Planz - 10 Jul 2003

Browser extensions for debugging