Solved

Transparent wrapper around DBI for debugging purposes

Posted on 2004-09-08
4
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Expert Comment

by:kandura
ID: 12004898
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
ID: 12004939
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…

734 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