Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created September 8, 2010 14:23
Show Gist options
  • Save jjn1056/570197 to your computer and use it in GitHub Desktop.
Save jjn1056/570197 to your computer and use it in GitHub Desktop.
package Catalyst::TraitFor::Model::DBIC::Schema::QueryLog::PlackDebugPanel;
use Moose::Role;
our $VERSION = "0.01";
around 'ACCEPT_CONTEXT', sub {
my ($orig, $self, $ctx) = @_;
$self = $self->$orig($ctx);
$ctx->engine->env->{'plack.middleware.querylog'} = $self->querylog
if defined $ctx->engine->env;
return $self;
};
1;
package Plack::Middleware::Debug::Catalyst::DBIC::QueryLog;
use strict;
use warnings;
use parent qw(Plack::Middleware::Debug::Base);
our $VERSION = "0.01";
sub run {
my ( $self, $env, $panel ) = @_;
return sub {
$panel->title('Catalyst::DBIC::QueryLog');
$panel->nav_subtitle("Catalyst::DBIC::QueryLog");
use Data::Dump;
my $dump = Data::Dump::dump $env->{'plack.middleware.querylog'};
$panel->content($dump);
};
}
1;
## Then in your myapp.conf or whatever...
'Model::Schema' => {
schema_class => 'MyApp::Schema',
traits => ['QueryLog','QueryLog::PlackDebugPanel'],
connect_info => {
dsn => 'dbi:SQLite:dbname=__path_to(share,var,sqlite.db)__',
},
querylog_args => {
passthrough => 1,
},
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment