first shot at DBI tracing code
This commit is contained in:
parent
0c08e9c235
commit
5b25692561
3 changed files with 62 additions and 5 deletions
|
|
@ -132,9 +132,7 @@ sub execute {
|
|||
my $self = shift;
|
||||
my $placeholders = shift || [];
|
||||
my $sql = $self->{_sql};
|
||||
my $errorHandler = $self->db->session->errorHandler;
|
||||
$errorHandler->query($sql,$placeholders);
|
||||
$self->sth->execute(@{ $placeholders }) or $errorHandler->fatal("Couldn't execute prepared statement: $sql : With place holders: ".join(", ", @{$placeholders}).". Root cause: ". $self->errorMessage);
|
||||
$self->sth->execute(@{ $placeholders }) or $self->session->errorHandler->fatal("Couldn't execute prepared statement: $sql : With place holders: ".join(", ", @{$placeholders}).". Root cause: ". $self->errorMessage);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
55
lib/WebGUI/SQL/Trace.pm
Normal file
55
lib/WebGUI/SQL/Trace.pm
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
package WebGUI::SQL::Trace;
|
||||
use strict;
|
||||
#use warnings;
|
||||
use 5.008008;
|
||||
|
||||
our $VERSION = '0.0.1';
|
||||
|
||||
sub PUSHED {
|
||||
my ($class, $mode, $fh) = @_;
|
||||
my $logger;
|
||||
return bless \$logger, $class;
|
||||
}
|
||||
|
||||
sub OPEN {
|
||||
my ($self, $session, $mode, $fh) = @_;
|
||||
$$self = $session;
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub WRITE {
|
||||
my ($self, $buf, $fh) = @_;
|
||||
if ($buf =~ /\ABinding parameters: /) {
|
||||
my $sql = $buf;
|
||||
$sql =~ s/\ABinding parameters: //;
|
||||
my $sub;
|
||||
my $line;
|
||||
for ( my $i = 0; caller($i); $i++) {
|
||||
(my $package, undef, $line) = caller($i);
|
||||
next
|
||||
if $package eq 'WebGUI::SQL';
|
||||
next
|
||||
if $package eq 'WebGUI::SQL::ResultSet';
|
||||
($sub) = (caller($i + 1))[3];
|
||||
last;
|
||||
}
|
||||
$$self->log->debug("Query - $sub($line) : $sql");
|
||||
}
|
||||
return length($buf);
|
||||
}
|
||||
|
||||
sub CLOSE {
|
||||
my $self = shift;
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
PerlIO::via::WebGUI - Log DBI output to WebGUI
|
||||
|
||||
=cut
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue