summary refs log tree commit diff
path: root/lib/Plack/Middleware/Debug/Dancer
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Plack/Middleware/Debug/Dancer')
-rw-r--r--lib/Plack/Middleware/Debug/Dancer/Logger.pm30
1 files changed, 11 insertions, 19 deletions
diff --git a/lib/Plack/Middleware/Debug/Dancer/Logger.pm b/lib/Plack/Middleware/Debug/Dancer/Logger.pm
index 487967c..368c62a 100644
--- a/lib/Plack/Middleware/Debug/Dancer/Logger.pm
+++ b/lib/Plack/Middleware/Debug/Dancer/Logger.pm
@@ -8,27 +8,18 @@ use parent qw(Plack::Middleware::Debug::Base);
 use Dancer::Logger;
 use Class::Method::Modifiers qw(install_modifier);
 
-# XXX Not thread/Coro/AE safe. Should use $c->env or something
+# # XXX Not thread/Coro/AE safe. Should use $c->env or something
 my $psgi_env;
-install_modifier 'Dancer::Logger', 'around', 'warning' => sub {
-    my $orig = shift;
-    my $self = shift;
-    _add_log( 'warning', $_[0] );
-    $self->$orig(@_);
+install_modifier 'Dancer::Logger', 'before', 'error' => sub {
+    _add_log( 'error', @_ );
 };
 
-install_modifier 'Dancer::Logger', 'around', 'error' => sub {
-    my $orig = shift;
-    my $self = shift;
-    _add_log( 'error', $_[0] );
-    $self->$orig(@_);
+install_modifier 'Dancer::Logger', 'before', 'warning' => sub {
+    _add_log( 'warning', @_ );
 };
 
-install_modifier 'Dancer::Logger', 'around', 'debug' => sub {
-    my $orig = shift;
-    my $self = shift;
-    _add_log( 'debug', $_[0] );
-    $self->$orig(@_);
+install_modifier 'Dancer::Logger', 'before', 'debug' => sub {
+    _add_log( 'debug', @_ );
 };
 
 sub _add_log {
@@ -42,15 +33,16 @@ sub run {
 
     return sub {
         my $res = shift;
-
         $panel->title('Dancer::Logger');
         $panel->nav_subtitle('Dancer::Logger');
-        my $logs = delete $env->{'plack.middleware.dancer_log'};
-        $panel->content( sub { $self->render_list_pairs($logs) } );
+        my $logs = delete $env->{'plack.middleware.dancer_log'}
+          if $env->{'plack.middleware.dancer_log'};
+        $panel->content( sub { $self->render_list_pairs($logs) } ) if $logs;
         $psgi_env = undef;
     };
 }
 
+
 1;
 
 =head1 SYNOPSIS