Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

(jeffa) Re: How to report call stack for DBI queries

by jeffa (Bishop)
on Apr 17, 2003 at 18:07 UTC ( #251277=note: print w/replies, xml ) Need Help??


in reply to How to report call stack for DBI queries

Maybe jdporter's Hook::WrapSub would be useful here? Something like:
use strict; use warnings; use DBI; use Data::Dumper; use Hook::WrapSub qw( wrap_subs unwrap_subs ); wrap_subs \&log_prepare, 'DBI::db::prepare'; wrap_subs \&log_execute, 'DBI::st::execute'; my $dbh = DBI->connect( qw(DBI:driver:database:host user pass), {RaiseError=>1} ); my $sth = $dbh->prepare('select foo,bar from qux'); $sth->execute(); $sth->finish(); $dbh->disconnect; unwrap_subs qw(DBI::db::prepare DBI::st::execute); # just announce we were called and dump our args sub log_prepare { print "prepare called:\n", Dumper \@_; } sub log_execute { print "execute called:\n", Dumper \@_; }

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: How to report call stack for DBI queries
by mp (Deacon) on Apr 17, 2003 at 18:26 UTC
    Jeffa, thank you. This is exactly what I needed.

    I am planning to use this to create a log that identifies where database queries are being prepared/executed after having used DBI::ProfileDumper to profile the queries in a mod_perl application.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://251277]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2022-05-28 13:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (99 votes). Check out past polls.

    Notices?