[Catalyst] sql debugging hooks

Tomas Doran bobtfish at bobtfish.net
Sat Jul 11 23:49:51 GMT 2009


On 11 Jul 2009, at 19:45, Minty wrote:
> But I want to inject my $debugger via the Model or schema, and
> enable/disable it globablly via a configuration file flag.
>
> I'm a bit lost as to where/how I can do that.  Any pointers?

package MyApp::Model::DB;
use Moose;
use namespace::autoclean;

extends 'Catalyst::Model::DBIC::Schema';

__PACKAGE__->config(debug => 1);

after 'BUILD' => sub {
     my ($self, $args) = @_;
     if ($args->{debug}) {
           my $debugger = My::Model::Debugger->new();
          $self->result_source->storage->debugobj($debugger);
          $self->result_source->storage->debug(1);
     }
}

# Try something like that, untested...

Cheers
t0m




More information about the Catalyst mailing list