diff options
Diffstat (limited to 'lib/Plack')
-rw-r--r-- | lib/Plack/Middleware/Debug/Dancer/Logger.pm | 49 | ||||
-rw-r--r-- | lib/Plack/Middleware/Debug/Dancer/Session.pm | 18 | ||||
-rw-r--r-- | lib/Plack/Middleware/Debug/Dancer/Settings.pm | 30 | ||||
-rw-r--r-- | lib/Plack/Middleware/Debug/Dancer/Version.pm | 15 | ||||
-rw-r--r-- | lib/Plack/Middleware/Debug/Dancer/logs/production.log | 16 |
5 files changed, 128 insertions, 0 deletions
diff --git a/lib/Plack/Middleware/Debug/Dancer/Logger.pm b/lib/Plack/Middleware/Debug/Dancer/Logger.pm new file mode 100644 index 0000000..3fdc4e9 --- /dev/null +++ b/lib/Plack/Middleware/Debug/Dancer/Logger.pm @@ -0,0 +1,49 @@ +package Plack::Middleware::Debug::Dancer::Logger; +use 5.008; +use strict; +use warnings; +use parent qw(Plack::Middleware::Debug::Base); +use Dancer::Logger; +use Class::Method::Modifiers qw(install_modifier); +our $VERSION = '0.07'; + +# 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; + $psgi_env->{'plack.middleware.dancer_log'} .= "[warning] $_[0]\n"; + $self->$orig(@_); +}; + +install_modifier 'Dancer::Logger', 'around', 'error' => sub { + my $orig = shift; + my $self = shift; + $psgi_env->{'plack.middleware.dancer_log'} .= "[error] $_[0]\n"; + $self->$orig(@_); +}; + +install_modifier 'Dancer::Logger', 'around', 'debug' => sub { + my $orig = shift; + my $self = shift; + $psgi_env->{'plack.middleware.dancer_log'} .= "[debug] $_[0]\n"; + $self->$orig(@_); +}; + +sub run { + my($self, $env, $panel) = @_; + $psgi_env = $env; + + return sub { + my $res = shift; + + my $log = delete $env->{'plack.middleware.dancer_log'}; + if ($log) { + $panel->content("<pre>$log</pre>"); + } + $psgi_env = undef; + }; +} + +1; +__END__ diff --git a/lib/Plack/Middleware/Debug/Dancer/Session.pm b/lib/Plack/Middleware/Debug/Dancer/Session.pm new file mode 100644 index 0000000..055676a --- /dev/null +++ b/lib/Plack/Middleware/Debug/Dancer/Session.pm @@ -0,0 +1,18 @@ +package Plack::Middleware::Debug::Dancer::Session; +use 5.008; +use strict; +use warnings; +use parent qw(Plack::Middleware::Debug::Base); +use Dancer::Session; + +sub run { + my ( $self, $env, $panel ) = @_; + + return sub { + my $session = Dancer::Session->get(); + my @settings = map { $_ => $session->{$_}} keys %$session; + $panel->content( sub { $self->render_list_pairs( \@settings ) } ); + }; +} + +1; diff --git a/lib/Plack/Middleware/Debug/Dancer/Settings.pm b/lib/Plack/Middleware/Debug/Dancer/Settings.pm new file mode 100644 index 0000000..cf10748 --- /dev/null +++ b/lib/Plack/Middleware/Debug/Dancer/Settings.pm @@ -0,0 +1,30 @@ +package Plack::Middleware::Debug::Dancer::Settings; +use 5.008; +use strict; +use warnings; +use parent qw(Plack::Middleware::Debug::Base); +use Class::Method::Modifiers qw/install_modifier/; +use Dancer::Config; + +#my $psgi_env; +# install_modifier 'Dancer', 'around', 'start' => sub { +# my $orig = shift; +# my $self = shift; +# $psgi_env->{'plack.middleware.dancer_settings'} = $self->config; +# $self->$orig(@_); +# }; + +sub run { + my ( $self, $env, $panel ) = @_; +# $psgi_env = $env; + + return sub { + my $res = shift; + my $settings = Dancer::Config->settings(); +# my $settings = $env->{'plack.middleware.dancer_settings'}; + my @settings = map { $_ => $settings->{$_}} keys %$settings; + $panel->content( sub { $self->render_list_pairs( \@settings ) } ); + }; +} + +1; diff --git a/lib/Plack/Middleware/Debug/Dancer/Version.pm b/lib/Plack/Middleware/Debug/Dancer/Version.pm new file mode 100644 index 0000000..fe05275 --- /dev/null +++ b/lib/Plack/Middleware/Debug/Dancer/Version.pm @@ -0,0 +1,15 @@ +package Plack::Middleware::Debug::Dancer::Version; +use 5.008; +use strict; +use warnings; +use parent qw(Plack::Middleware::Debug::Base); + +sub run { + my ( $self, $env, $panel ) = @_; + + return sub { + $panel->nav_subtitle($Dancer::VERSION); + }; +} + +1; diff --git a/lib/Plack/Middleware/Debug/Dancer/logs/production.log b/lib/Plack/Middleware/Debug/Dancer/logs/production.log new file mode 100644 index 0000000..8ebe41b --- /dev/null +++ b/lib/Plack/Middleware/Debug/Dancer/logs/production.log @@ -0,0 +1,16 @@ +[30912] warn @0.000413> [hit #1] THIS IS A LOG in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] error @0.000553> [hit #1] THIS IS AN ERROR in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] warn @0.000390> [hit #4] THIS IS A LOG in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] error @0.000515> [hit #4] THIS IS AN ERROR in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] warn @0.000402> [hit #6] THIS IS A LOG in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] error @0.000521> [hit #6] THIS IS AN ERROR in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] warn @0.000434> [hit #8] THIS IS A LOG in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] error @0.000558> [hit #8] THIS IS AN ERROR in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] warn @0.000420> [hit #9] THIS IS A LOG in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30912] error @0.000549> [hit #9] THIS IS AN ERROR in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30991] warn @0.000388> [hit #1] THIS IS A LOG in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[30991] error @0.001183> [hit #1] THIS IS AN ERROR in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[31205] warn @0.000421> [hit #1] THIS IS A LOG in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[31205] error @0.000535> [hit #1] THIS IS AN ERROR in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[31260] warn @0.000435> [hit #1] THIS IS A LOG in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 +[31260] error @0.000549> [hit #1] THIS IS AN ERROR in /home/franck/perl5/perlbrew/perls/perl-5.12.0/lib/site_perl/5.12.0/Class/Method/Modifiers.pm l. 74 |