summary refs log tree commit diff
path: root/lib/Plack/Middleware
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-08-02 21:24:24 +0200
committerfranck cuny <franck@lumberjaph.net>2010-08-02 21:24:24 +0200
commita9f75bfcfa2a3f9daac927ddfe047e439eb6fad3 (patch)
tree4b43c99e937ce307813a1ad4dd54e3afd20f6656 /lib/Plack/Middleware
parentupdate POD; update version and changes (diff)
downloaddancer-debug-a9f75bfcfa2a3f9daac927ddfe047e439eb6fad3.tar.gz
don't need around, before is enough; don't render log if none
Diffstat (limited to 'lib/Plack/Middleware')
-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