=head1 NAME Plack::Middleware::Debug::DBIC::QueryLog - Log DBIC Queries =head2 SYNOPSIS Adds a debug panel and querylog object for logging L queries. Has support for L via a L compatible trait, L. use Plack::Builder; my $app = ...; ## Build your Plack App builder { enable 'Debug::DBIC::QueryLog', querylog_args => {passthrough => 1}; $app; }; And in you L application, if you are also using L package MyApp::Web::Model::Schema; use parent 'Catalyst::Model::DBIC::Schema'; __PACKAGE__->config({ schema_class => 'MyApp::Schema', traits => ['QueryLog::AdoptPlack'], ## .. rest of configuration }); 1; =head1 DESCRIPTION L is a tool in the L software ecosystem which benchmarks queries. It lets you log the SQL that L is generating, along with bind variables and timestamps. You can then pass the querylog object to an analyzer (such as L) to generate sorted statistics for all the queries between certain log points. Query logging in L is supported for L via a trait for L called L. This trait will log all the SQL used by L for a given request cycle. This is very useful since it can help you identify troublesome or bottlenecking queries. However, L does not provide out of the box outputting of your analyzed query logs. Usually you need to add a bit of templating work to the bottom of your webpage footer, or dump the output to the logs. We'd like to provide a lower ceremony experience. Additionally, it would be nice if we could provide this functionality for all L based applications, not just L. Ideally we'd play nice with L so that the table of our querylog would appear as a neat Plack based Debug panel. This bit of middleware provides that function. Basically we create a new instance of L and place it into C<< $env->{'plack.middleware.debug.dbic.querylog'} >> so that it is accessible by all applications running inside of L. You need to 'tell' your application's instance of L to use this C<$env> key and make sure you set L's debug object correctly: my $querylog = $ctx->engine->env->{'plack.middleware.debug.dbic.querylog'}; $schema->storage->debugobj($querylog); $schema->storage->debug(1); That way when you view the debug panel, we have SQL to review. If you are using L and a modern L you can use the trait L, which is compatible with L. See the L example for more details. =head1 OPTIONS This debug panel defines the following options. =head2 querylog Takes a L object, which is used as the querylog for the application. If you don't provide this, we will build one automatically, using L if provided. Generally you will use this only if you are instantiating a querylog object outside your L based application, such as in an IOC container like L. =head2 querylog_args Takes a HashRef which is passed to L at construction. =head1 SEE ALSO L, L, L, L =head1 AUTHOR John Napiorkowski, C<< >> =head1 COPYRIGHT & LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut