Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Transparent wrapper around DBI for debugging purposes

Posted on 2004-09-08
4
Medium Priority
?
371 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Six Sigma Control Plans

670 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