summary refs log tree commit diff
path: root/lib/Plack
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-04-18 19:23:07 +0200
committerfranck cuny <franck@lumberjaph.net>2010-04-18 19:23:07 +0200
commit6cc949a70010c285308fae31eb6c6289a7c0fbd6 (patch)
treee85fef933ba2d741f6ab6573577353842cec7f42 /lib/Plack
parentset title and subtitle (diff)
downloaddancer-debug-6cc949a70010c285308fae31eb6c6289a7c0fbd6.tar.gz
log in table
Diffstat (limited to 'lib/Plack')
-rw-r--r--lib/Plack/Middleware/Debug/Dancer/Logger.pm19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/Plack/Middleware/Debug/Dancer/Logger.pm b/lib/Plack/Middleware/Debug/Dancer/Logger.pm
index 91f0cdc..61b904f 100644
--- a/lib/Plack/Middleware/Debug/Dancer/Logger.pm
+++ b/lib/Plack/Middleware/Debug/Dancer/Logger.pm
@@ -11,26 +11,31 @@ my $psgi_env;
 install_modifier 'Dancer::Logger', 'around', 'warning' => sub {
     my $orig = shift;
     my $self = shift;
-    $psgi_env->{'plack.middleware.dancer_log'} .= "[warning] $_[0]\n";
+    _add_log( 'warning', $_[0] );
     $self->$orig(@_);
 };
 
 install_modifier 'Dancer::Logger', 'around', 'error' => sub {
     my $orig = shift;
     my $self = shift;
-    $psgi_env->{'plack.middleware.dancer_log'} .= "[error] $_[0]\n";
+    _add_log( 'error', $_[0] );
     $self->$orig(@_);
 };
 
 install_modifier 'Dancer::Logger', 'around', 'debug' => sub {
     my $orig = shift;
     my $self = shift;
-    $psgi_env->{'plack.middleware.dancer_log'} .= "[debug] $_[0]\n";
+    _add_log( 'debug', $_[0] );
     $self->$orig(@_);
 };
 
+sub _add_log {
+    my ( $level, $msg ) = @_;
+    push @{ $psgi_env->{'plack.middleware.dancer_log'} }, $level, $msg;
+}
+
 sub run {
-    my($self, $env, $panel) = @_;
+    my ( $self, $env, $panel ) = @_;
     $psgi_env = $env;
 
     return sub {
@@ -38,10 +43,8 @@ sub run {
 
         $panel->title('Dancer::Logger');
         $panel->nav_subtitle('Dancer::Logger');
-        my $log = delete $env->{'plack.middleware.dancer_log'};
-        if ($log) {
-            $panel->content("<pre>$log</pre>");
-        }
+        my $logs = delete $env->{'plack.middleware.dancer_log'};
+        $panel->content( sub { $self->render_list_pairs($logs) } );
         $psgi_env = undef;
     };
 }