From: Matt S Trout Date: Tue, 30 May 2006 19:30:52 +0000 (+0000) Subject: fixed debugfh X-Git-Tag: v0.07002~75^2~149 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=004d31fb32adad68450ac2fc836430b2b0d2cc83;p=dbsrgits%2FDBIx-Class.git fixed debugfh --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 46ac1cb..7802921 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -250,7 +250,7 @@ sub new { } else { $fh = IO::File->new('>&STDERR'); } - $new->debugobj->debugfh($fh); + $new->debugfh($fh); $new->debug(1) if $ENV{DBIX_CLASS_STORAGE_DBI_DEBUG}; return $new; } @@ -327,6 +327,16 @@ an IO::Handle compatible ojbect (only the C method is used. Initially set to be STDERR - although see information on the L environment variable. +=cut + +sub debugfh { + my $self = shift; + + if ($self->debugobj->can('debugfh')) { + return $self->debugobj->debugfh(@_); + } +} + =head2 debugobj Sets or retrieves the object used for metric collection. Defaults to an instance @@ -343,11 +353,12 @@ SELECT/INSERT/UPDATE/DELETE and $info is what would normally be printed. See L for a better way. =cut + sub debugcb { - my $self = shift(); + my $self = shift; - if($self->debugobj()->can('callback')) { - $self->debugobj()->callback(shift()); + if ($self->debugobj->can('callback')) { + return $self->debugobj->callback(@_); } } diff --git a/t/91debug.t b/t/91debug.t new file mode 100644 index 0000000..4f9d1d9 --- /dev/null +++ b/t/91debug.t @@ -0,0 +1,21 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest->init_schema(); + +plan tests => 2; + +ok ( $schema->storage->debug(1), 'debug' ); +ok ( defined( + $schema->storage->debugfh( + IO::File->new('t/var/sql.log', 'w') + ) + ), + 'debugfh' + ); + +1;