Expose a DBIC QueryLog in Middleware for Perl's Plack web superglue!
Switch branches/tags
Nothing to show
Pull request Compare This branch is 19 commits behind jjn1056:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Plack::Middleware::DBIC::QueryLog - Expose a DBIC QueryLog in Middleware


use Plack::Builder;
builder {
    enable 'DBIC::QueryLog',
      querylog_args => {passthrough => 1};


Plack::Middleware::DBIC::QueryLog does one thing, it places an object that is either an instance of DBIx::Class::QueryLog OR a compatible object into the $env under plack.middleware.dbic.querylog.

The querylog is intended to be used DBIX::Class to log and profile SQL queries, particularly during the context of a web request handled by your Plack application. See the documentation for DBIx::Class::QueryLog and in LDBIx::Class::Storage/debugobj for more information.

This middleware is intended to act as a bridge between DBIx::Class, which can consume and populate the querylog, with a reporting tool such as seen in Plack::Middleware::Debug::DBIC::QueryLog. This functionality was refactored out of 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) rather than building something custom around this middleware.

If you are using an existing web application development system such as Catalyst, you can use Catalyst::TraitFor::Model::DBIC::Schema::QueryLog::AdoptPlack to 'hook' the query log into your 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.


Used like any other Plack based middlewares.


This middleware accepts the following arguments.


Accepts an instance of DBIx::Class::QueryLog or compatible object. If you need a custom version of this, or are mocking the interface, consider looking at LPlack::Util/inline_object.

If you just want to pass arguments to DBIx::Class::QueryLog you can use the L</querylog_args>. This argument is provided if you have complicated or very customized instantiation needs, or your are using an IOC container or similar tool, such as Bread::Board


This is the class which is used to build the L unless one is already defined. It defaults to DBIx::Class::QueryLog. You should probably leave this alone unless you need to subclass or augment DBIx::Class::QueryLog.

If the class name you pass has not already been included (via use or require) we will automatically include it. If the class name can't be found or loaded, an error will be reported.


Accepts a HashRef of data which will be passed to L</"querylog_class"> when building the L</"querylog">, unless a </"querylog"> is already defined.


Plack, Plack::Middleware, Plack::Middleware::Debug::DBIC::QueryLog, Catalyst::TraitFor::Model::DBIC::Schema::QueryLog::AdoptPlack


John Napiorkowski, <jjnapiork@cpan.org>


This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.