# NAME
Plack::Middleware::DBIC::QueryLog - Expose a DBIC QueryLog Instance in Middleware
# SYNOPSIS
use Plack::Builder;
builder {
enable 'DBIC::QueryLog',
querylog_args => {passthrough => 1};
$app;
};
# DESCRIPTION
[Plack::Middleware::DBIC::QueryLog](
http://search.cpan.org/perldoc?Plack::Middleware::DBIC::QueryLog) does one thing, it places an object that
is either an instance of [DBIx::Class::QueryLog](
http://search.cpan.org/perldoc?DBIx::Class::QueryLog) OR a compatible object into
the `$env` under `plack.middleware.dbic.querylog`. A new instance is created
for each incoming request.
The querylog is intended to be used by [DBIX::Class](
http://search.cpan.org/perldoc?DBIX::Class) to log and profile SQL
queries, particularly during the context of a web request handled by your
[Plack](
http://search.cpan.org/perldoc?Plack) application. See the documentation for [DBIx::Class::QueryLog](
http://search.cpan.org/perldoc?DBIx::Class::QueryLog) and
in L<DBIx::Class::Storage/debugobj> for more information.
This middleware is intended to act as a bridge between [DBIx::Class](
http://search.cpan.org/perldoc?DBIx::Class), which
can consume and populate the querylog, with a reporting tool such as seen in
[Plack::Middleware::Debug::DBIC::QueryLog](
http://search.cpan.org/perldoc?Plack::Middleware::Debug::DBIC::QueryLog). This functionality was refactored
out of [Plack::Middleware::Debug::DBIC::QueryLog](
http://search.cpan.org/perldoc?Plack::Middleware::Debug::DBIC::QueryLog) to facilitate interoperation
with other types of reporting tools.
Unless you are building some custom logging tools, you probably just want to
use the existing debug panel ([Plack::Middleware::Debug::DBIC::QueryLog](
http://search.cpan.org/perldoc?Plack::Middleware::Debug::DBIC::QueryLog))
rather than building something custom around this middleware.
If you are using an existing web application development system such as [Catalyst](
http://search.cpan.org/perldoc?Catalyst),
you can use [Catalyst::TraitFor::Model::DBIC::Schema::QueryLog::AdoptPlack](
http://search.cpan.org/perldoc?Catalyst::TraitFor::Model::DBIC::Schema::QueryLog::AdoptPlack) to
'hook' the query log into your [DBIx::Class](
http://search.cpan.org/perldoc?DBIx::Class) schema model. If you are using
a different framework, or building your own, please consider releasing your
code or sending me a document patch suitable for including in a workbook or FAQ.
# USAGE
Used like any other [Plack](
http://search.cpan.org/perldoc?Plack) based middlewares.
# ARGUMENTS
This middleware accepts the following arguments.
## querylog_class
This is the class which is used to build the `querylog` unless one is already
defined. It defaults to [DBIx::Class::QueryLog](
http://search.cpan.org/perldoc?DBIx::Class::QueryLog). You should probably leave
this alone unless you need to subclass or augment [DBIx::Class::QueryLog](
http://search.cpan.org/perldoc?DBIx::Class::QueryLog).
If the class name you pass has not already been included (via `use` or
`require`) we will automatically try to c<require> it.
## querylog_args
Accepts a HashRef of data which will be passed to L</"querylog_class"> when
building the `querylog`.
# SEE ALSO
[Plack](
http://search.cpan.org/perldoc?Plack), [Plack::Middleware](
http://search.cpan.org/perldoc?Plack::Middleware), [Plack::Middleware::Debug::DBIC::QueryLog](
http://search.cpan.org/perldoc?Plack::Middleware::Debug::DBIC::QueryLog),
[Catalyst::TraitFor::Model::DBIC::Schema::QueryLog::AdoptPlack](
http://search.cpan.org/perldoc?Catalyst::TraitFor::Model::DBIC::Schema::QueryLog::AdoptPlack)
# AUTHOR
John Napiorkowski, `<
[email protected]>`
# COPYRIGHT & LICENSE
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.