Adds Plack::Middleware::Debug::WgLogger
This commit is contained in:
parent
b1ab8287ca
commit
2d7c8e637f
2 changed files with 32 additions and 1 deletions
31
lib/Plack/Middleware/Debug/WgLogger.pm
Normal file
31
lib/Plack/Middleware/Debug/WgLogger.pm
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
package Plack::Middleware::Debug::WgLogger;
|
||||||
|
use strict;
|
||||||
|
use parent qw(Plack::Middleware::Debug::Base);
|
||||||
|
our $VERSION = '0.07';
|
||||||
|
|
||||||
|
# This will be moved to the WebGUI::Middleware::Debug::WgLogger namespace
|
||||||
|
# once Plack::Middleware::Debug supports that
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, $env, $panel) = @_;
|
||||||
|
|
||||||
|
my $logger = $env->{'psgix.logger'};
|
||||||
|
|
||||||
|
my $log_output = [];
|
||||||
|
$env->{'psgix.logger'} = sub {
|
||||||
|
my $args = shift;
|
||||||
|
push @$log_output, $args->{level} => $args->{message};
|
||||||
|
$logger && $logger->($args);
|
||||||
|
};
|
||||||
|
delete $env->{'webgui.session'}->{_errorHandler};
|
||||||
|
|
||||||
|
return sub {
|
||||||
|
my $res = shift;
|
||||||
|
$panel->nav_subtitle(scalar @$log_output . " messages");
|
||||||
|
$panel->content($self->render_list_pairs($log_output));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub panel_name { 'WebGUI Log' }
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
@ -63,7 +63,7 @@ sub call {
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
$app = Plack::Middleware::StackTrace->wrap($app);
|
$app = Plack::Middleware::StackTrace->wrap($app);
|
||||||
$app = Plack::Middleware::Debug->wrap( $app,
|
$app = Plack::Middleware::Debug->wrap( $app,
|
||||||
panels => [qw(Environment Response Timer Memory Session DBITrace PerlConfig Response)] );
|
panels => [qw(Environment Response Timer Memory Session DBITrace PerlConfig Response WgLogger)] );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Turn exceptions into HTTP errors
|
# Turn exceptions into HTTP errors
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue