Solved

Transparent wrapper around DBI for debugging purposes

Posted on 2004-09-08
4
335 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Syslog text file into database or into .CSV 19 107
Perl - Mawk 2 87
add a syntax to a csv file 8 98
Removing permissions on a Cyrus mailbox via a wrapper script 3 88
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

932 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

15 Experts available now in Live!

Get 1:1 Help Now