Apr 26, 2003, 7:48 AM
Post #1 of 3
I have always hated how difficult debugging CGI is, so I decided to do something about it. I grabbed a copy of Perl Web Server form Source Forge and went to work.
CGI Debugging made easy + more!
After a coupla days a hack'n I had a web server that would eval my CGI scripts and CGI::Applications. I could now set a break point in my CGI script and start the web server in the debugger. Then open a browser to port the web server is listening. This allowed me to interact with my CGI script through the browser. I find this easier than setting every thing up on the command line, especially for queries with 20 or more name value pairs.
After getting the debugging down I saw that was just the tip of the ice burg for making CGI development and debugging easier.
I modified CGI and CGI::Carp to provide the option to save all state and request information from a fatal error with Storable to a file. I added a new page to my CGI script so I could view the detailed information in the error files. As well as the ability to execute the offending request. You say why would I want to execute the falling request again? You would want to do that from the debugging web site, in the Perl Web Server debugger. Then you can quickly track down where the error is and fix it.
No more sifting through logs, or having to guess what the user did to get the error they are reporting. Get right to it, and fix it.
I have plans to add a test harness to it so in development you can create the same files the CGI::Carp creates for fatal errors and use them as the test case input. Then save and associate the output from those successful for future tests. When an error occurs on your production system you can grab the error file that CGI::Carp generated and fix the problem. After fixing the problem you make a new output file and associate it with the error file generated by CGI::Carp and run the test harness with the old and new test case to see if you broke anything while fixing the bug.
So I have some questions for anyone that is reading this. Is this so specialized a solution to my needs that others would not find much use in it? If not how do I give this to the Perl community, is it a tool, a set of libs, a hack or some combination of those choices? Do I need to contact the authors of the modules I needed to modify before I submit it to the Perl community? I just don't know what etiquette is in this situation.