Solved

Transparent wrapper around DBI for debugging purposes

Posted on 2004-09-08
4
325 Views
Last Modified: 2009-07-29
I have a large code base (which runs under mod_perl) to which I would like to add some debugging code.

I would like to be able to run a bit of code everytime DBI is used to connect, prepare or execute. How can I add this debugging code _without_ editing every call to those methods and _without_ editing the DBI module itself.
0
Comment
Question by:dorward
  • 2
4 Comments
 
LVL 18

Expert Comment

by:kandura
Comment Utility
DBI can generate debugging information itself:

set
    DBI->trace(2 => "/tmp/logfile");
somewhere near the top of your script.
Or set the environment variable
    DBI_PROFILE=2

See manuals for DBI::Profile and DBI::Trace.

(Found this at http://www.class-dbi.com/cgi-bin/wiki/index.cgi?SeeAllSQL)
0
 
LVL 18

Accepted Solution

by:
kandura earned 500 total points
Comment Utility
Also see DBI::ProfileDumper::Apache.

Here's the synopsis from the manual:

Add this line to your httpd.conf:

  PerlSetEnv DBI_PROFILE DBI::ProfileDumper::Apache

Then restart your server. Access the code you wish to test using a web browser, then shutdown your server. This will create a set of dbi.prof.* files in your Apache log directory. Get a profiling report with dbiprof:

  dbiprof /usr/local/apache/logs/dbi.prof.*

When you're ready to perform another profiling run, delete the old files

  rm /usr/local/apache/logs/dbi.prof.*

and start again.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now