diff options
author | franck cuny <franck@lumberjaph.net> | 2010-04-18 19:23:07 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-04-18 19:23:07 +0200 |
commit | 6cc949a70010c285308fae31eb6c6289a7c0fbd6 (patch) | |
tree | e85fef933ba2d741f6ab6573577353842cec7f42 | |
parent | set title and subtitle (diff) | |
download | dancer-debug-6cc949a70010c285308fae31eb6c6289a7c0fbd6.tar.gz |
log in table
-rw-r--r-- | lib/Plack/Middleware/Debug/Dancer/Logger.pm | 19 |
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; }; } |