Giter Site home page Giter Site logo

plack-middleware-debug's Introduction

NAME

Plack::Middleware::Debug - display information about the current request/response

SYNOPSIS

enable "Debug";

DESCRIPTION

The debug middleware offers a configurable set of panels that displays information about the current request and response. The information is generated only for responses with a status of 200 (OK) and a Content-Type that contains text/html or application/xhtml+xml and is embedded in the HTML that is sent back to the browser.

Note that the code is injected directly before the closing tag (</body>) so if there is no such tag, the debug panel will not be injected at all.

To enable the middleware, just use Plack::Builder as usual in your .psgi file:

use Plack::Builder;

builder {
    enable 'Debug', panels => [ qw(DBITrace Memory Timer) ];
    $app;
};

The Debug middleware takes an optional panels argument whose value is expected to be a reference to an array of panel specifications. If given, only those panels will be enabled. If you don't pass a panels argument, the default list of panels - Environment, Response, Timer, Memory, Session and DBITrace - will be enabled, each with their default settings, and automatically disabled if their target modules or middleware components are not loaded.

Each panel specification can take one of three forms:

  • A string

    This is interpreted as the base name of a panel in the Plack::Middeware::Debug:: namespace, unless preceded by +, in which case it's interpreted as an absolute name similar to how Plack::Builder handles such names, e.g. +My::Plack::Middleware::Debug::Something.

    The panel class is loaded and a panel object is created with its default settings.

  • An array reference

    If you need to pass arguments to the panel object as it is created, you may use this form (But see below).

    The first element of the array reference has to be the panel base name. The remaining elements are key/value pairs to be passed to the panel.

    For example:

      builder {
          enable 'Debug', panels =>
            [ qw(Environment Response Timer Memory),
              [ 'DBITrace', level => 2 ]
            ];
          $app;
      };
    

    Because each panel is a middleware component, you can write this way as well:

      builder {
          enable 'Debug'; # load defaults
          enable 'Debug::DBITrace', level => 2;
          $app;
      };
    

    Note that the <enable 'Debug'> line should come before other Debug panels because of the order middleware components are executed.

  • Custom middleware

    You can also pass a Panel middleware component. This might be useful if you have custom debug panels in your framework or web application.

HOW TO WRITE YOUR OWN DEBUG PANEL

The Debug middleware is designed to be easily extensible. You might want to write a custom debug panel for your framework or for your web application. Each debug panel is also a Plack middleware component and is easy to write one.

Let's look at the anatomy of the Timer debug panel. Here is the code from that panel:

package Plack::Middleware::Debug::Timer;
use Time::HiRes;

use parent qw(Plack::Middleware::Debug::Base);

sub run {
    my($self, $env, $panel) = @_;

    my $start = [ Time::HiRes::gettimeofday ];

    return sub {
        my $res = shift;

        my $end = [ Time::HiRes::gettimeofday ];
        my $elapsed = sprintf '%.6f s', Time::HiRes::tv_interval $start, $end;

        $panel->nav_subtitle($elapsed);
        $panel->content(
            $self->render_list_pairs(
                [ Start  => $self->format_time($start),
                  End    => $self->format_time($end),
                  Elapsed => $elapsed ],
            ),
        );
    };
}

sub format_time { ... }

To write a new debug panel, place it in the Plack::Middleware::Debug:: namespace. In our example, the Timer panel lives in the Plack::Middleware::Debug::Timer package.

The only thing your panel should do is to subclass Plack::Middleware::Debug::Base. This does most of the things a middleware component should do as a Plack middleware, so you only need to override run method to profile and create the panel content.

sub run {
    my($self, $env, $panel) = @_;

    # Do something before the application runs

    return sub {
        my $res = shift;

        # Do something after the application returns

    };
}

You can create as many lexical variables as you need and reference that in the returned callback as a closure, and update the content of of the $panel which is Plack::Middleware::Debug::Panel object.

In our Timer example we want to list three key/value pairs: the start time, the end time and the elapsed time. We use the render_list_pairs() method to place the pairs in the order we want. There is also a render_hash() and render_lines() method, to render a hash keys and values, as well as just text lines (e.g. log messages).

BUGS AND LIMITATIONS

Please report any bugs or feature requests through the web interface at http://rt.cpan.org.

INSTALLATION

See perlmodinstall for information and options on installing Perl modules.

AVAILABILITY

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you. Or see http://search.cpan.org/dist/Plack-Middleware-Debug/.

The development version lives at http://github.com/miyagawa/plack-middleware-debug/. Instead of sending patches, please fork this project using the standard git and github infrastructure.

AUTHORS

Marcel Grunauer, <[email protected]>

Tatsuhiko Miyagawa, <[email protected]>

COPYRIGHT AND LICENSE

Copyright 2009 by Marcel Grünauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

The debug middleware is heavily influenced (that is, adapted from) the Django Debug Toolbar - see http://github.com/robhudson/django-debug-toolbar.

plack-middleware-debug's People

Contributors

avar avatar chizmw avatar dracos avatar dsteinbrunner avatar fcuny avatar genehack avatar haarg avatar jjn1056 avatar jonswar avatar kes777 avatar mattias-p avatar miyagawa avatar oalders avatar omega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

plack-middleware-debug's Issues

Doesn't list deps properly

dzil listdeps doesn't include Test::Requires, so installation fails during testing phase.

t/parameters-leak.t ..... Can't locate Test/Requires.pm in @INC (you may need to install the   
Test::Requires module) (@INC contains: /Users/genehack/Desktop/Plack-Middleware-
Debug/.build/DD7ZUc7CCK/blib/arch /Users/genehack/Desktop/Plack-Middleware-
Debug/.build/DD7ZUc7CCK/blib/lib /opt/plenv/versions/5.20.0/lib/perl5/site_perl/5.20.0/darwin-2level 
/opt/plenv/versions/5.20.0/lib/perl5/site_perl/5.20.0 /opt/plenv/versions/5.20.0/lib/perl5/5.20.0/darwin-
2level /opt/plenv/versions/5.20.0/lib/perl5/5.20.0 .) at t/parameters-leak.t line 4.
BEGIN failed--compilation aborted at t/parameters-leak.t line 4.

spam in log file

Can not figure out from where it is comming, so post here. If it is your module please fix. Thank you.

I just use something from box app.psgi:

use HTML::Mason::PSGIHandler;

my $h = HTML::Mason::PSGIHandler->new(
       comp_root => "/home/feelsafe/public_html/www",
);

my $app = sub {
       my $env = shift;
       $h->handle_psgi($env);
};


use Plack::Builder;

builder {
    enable "StackTrace";
    enable "Debug";
    enable "Debug::HTML::Mason";
    enable "Debug::Session";
    $app;
};

and /test.html

<%flags>
inherit => undef
</%flags>

% die "Hello";

And in uwsgi.log file I have:

----------------------------------------------------------------------------
Use of uninitialized value in concatenation (.) or string at line 11 in template passed from /usr/share/perl5/Plack/Middl
eware/Debug.pm at line 118.
----------------------------------------------------------------------------
   9:     }
  10: </script>
  11: <script type="text/javascript" src="<%= $stash->{BASE_URL} %>/debug_toolbar/toolbar.min.js"></script>
  12: <script type="text/javascript" charset="utf-8">
  13:     // Now that jQuery is done loading, put the '$' variable back to what it was...
----------------------------------------------------------------------------
Use of uninitialized value $_MT_T in substitution (s///) at line 17 in template passed from /usr/share/perl5/Plack/Middle
ware/Debug.pm at line 118.
----------------------------------------------------------------------------
  15: </script>
  16: <style type="text/css">
  17:     @import url(<%= $stash->{BASE_URL} %>/debug_toolbar/toolbar.min.css);
  18: </style>
  19: <div id="plDebug">
----------------------------------------------------------------------------
Use of uninitialized value in concatenation (.) or string at line 17 in template passed from /usr/share/perl5/Plack/Middl
eware/Debug.pm at line 118.
----------------------------------------------------------------------------
  15: </script>
  16: <style type="text/css">
  17:     @import url(<%= $stash->{BASE_URL} %>/debug_toolbar/toolbar.min.css);
  18: </style>
  19: <div id="plDebug">
----------------------------------------------------------------------------

FR: implement option for 'Parameters'

Please implement option to allow print hash value in 'pre' block.
because this session value for 'customer' key is not readable.

{ balance => "15.00", contact => { address => "11-11 Victoria house", alias => undef, branch => undef,
 cellular => "", ci", company => "", country => "SC", department => undef, email => "dezay", fax => 
undef, firstname => "John", id => 12464, lastname => "Pupkin", messenger => undef, middlename => 
undef, notes => "", phone => "52", photo => undef, properties => undef, role => undef, skype => "", 
sms => "", sms_warnings => undef, state => "Mahe", title => undef, zip => "00000", }, contact_id => 
12464, discount_apply_date => undef, discount_policy => { id => 1, name => "none" }, 
discount_policy_id => 1, emcallorder => 0, emcalltime => 1365617084, id => 12467, login => " notes 
=> "", password => "{S", payment_methods => ["dalpay", "paypal"], site => { active => 1, description => 
"", hostname => "ot", id => 1, main_site =>members_site => "meet", notes => "", priority => 0, }, site_id 
=> 1, state => 1, }

Problems using jQuery 3.x

Having this simple index.html

<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
	<title>test</title>
</head>
	<body>
	Hello <span id="test">xxx</span>!
	<script   src="https://code.jquery.com/jquery-3.1.1.slim.min.js"   integrity="sha256-/SIrNqv8h6QGKDuNoLGA4iret+kyesCkHGzVUUV0shc="   crossorigin="anonymous"></script>
<!--
	<script   src="https://code.jquery.com/jquery-2.2.4.min.js"   integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="   crossorigin="anonymous"></script>
	<script   src="https://code.jquery.com/jquery-1.12.4.min.js"   integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="   crossorigin="anonymous"></script>
-->

<script>
$(document).ready(function(){
	$("#test").text("world");
});
</script>
	</body>
</html>

Run: plackup -MPlack::App::Directory -MPlack::Builder -e 'builder{enable q{Debug}; Plack::App::Directory->new(root=>".")};'

Point the browser to: http://localhost:5000/index.html

Got the following error (using Safari's web-inspector):

[Error] TypeError: b(document).bind is not a function. (In 'b(document).bind', 'b(document).bind' is undefined)
	(anonymous function) (jquery-3.1.1.slim.min.js:2:31859)
[Error] TypeError: b(document).unbind is not a function. (In 'b(document).unbind("keydown.plDebug")', 'b(document).unbind' is undefined)
	(anonymous function) (jquery-3.1.1.slim.min.js:2:31859)

Also, clicking the big ? (Show Toolbar) produces more errors like:

[Error] TypeError: b(document).bind is not a function. (In 'b(document).bind("keydown.plDebug",function(d){if(d.keyCode==27){b.plDebug.close()}})', 'b(document).bind' is undefined)
	show_toolbar (toolbar.min.js:1:1973)
	(anonymous function) (toolbar.min.js:1:1393)
	dispatch (jquery-3.1.1.slim.min.js:3:10565)

No errors using jQuery 2.x or 1.x. Unfortunately i don't know javascript, so can't track down the problem in more details.

Javascript/CSS URLs are broken when running under FastCGI

Hi, found a small bug:

The URLs in the debug panel's inserted HTML have $env->{SCRIPT_NAME} prepended to them, which was ok under HTTP::Server::PSGI because that variable seems to be empty there. However with FastCGI (on Lighttpd) it gets set to the relative part of the current URL, so all paths end up wrong (e.g. I get /login/debug_toolbar/jquery.js instead of /debug_toolbar/jquery.js).

I've noticed $PATH_INFO and $SCRIPT_NAME seem to be swapped between the two servers, maybe that has something to do with it?

Debug panel is not showed

Running application the debug panel is not showed. Returned HMLT has only "Hello World"
No errors or warning messages appeared.
'Hi' message is successfully logged

use Modern::Perl;
use HTML::Mason::PSGIHandler;

use Log::Log4perl;
Log::Log4perl->init( '/home/user/public_html/log4perl.conf' );

my $app2 = sub {
    my $env =  shift;

    my $log =  Log::Log4perl::get_logger();
    $log->error( 'Hi' );

    return [
        '200',
        [ 'Content-Type' => 'text/plain' ],
        [ "Hello World" ],
    ];
};


use Plack::Builder;
use Plack::Middleware::Debug::Log4perl;
my $b =  builder {
    enable "Debug", panels => [ 'Log4perl' ];
    $app2;
}

Apply debug panel to only certain PATH_INFO

Plack::Middleware::Debug currently applies to all routes but only adds the html to the end of the html body if the mime type and response codes are correct.

However, this means the debug panel pre-app and post-app code is run for every route which might be quite slow.

It would be nice if Plack::Middleware::Debug took matches => [qr//] and/or skips => [qr//] that matches against $env->{PATH_INFO}.
I've implemented a prototype of this, is this approach sensible? if so I'll raise a PR.

memory leak using dbitrace

memory leak using dbitrace

I have started to use dbi module now and the dbi trace information is displayed correctly.

However, there seems to be another leak.

Track objects indicates that more and more of these entries reside in memory:

<table> <tbody> <tr class="plDebugEven"> <td> DBI 1.613-ithread d.......
C:/strawberry/perl/site/lib/Text/MicroTemplate.pm
line 437

using the following code:

in my_app.psgi, I use

sub import {
    use Devel::TrackObjects qr/^/;
}

Then

builder {
enable 'Debug', panels =>
[ qw(Environment Response Timer WindowsMemory Session TrackObjects),
[ 'DBITrace', level => 2 ]
];
and in TrackObjects:

package Plack::Middleware::Debug::TrackObjects;

use parent qw(Plack::Middleware::Debug::Base);

sub run {
    my($self, $env, $panel) = @_;

    return sub {
        my $res = shift;

        my $track = Devel::TrackObjects->show_tracked_detailed;
        my @content;

        foreach (@$track){
            if (length($_->[0]) > 100){
                $_->[0] = substr($_->[0],$i,100);
            }
            push @content, $_->[0], $_->[1].' - '.$_->[2];
        }

        $panel->nav_subtitle('Number:'.scalar(@content)/2);

        $panel->content(
            $self->render_list_pairs([@content])
        );
    };

}

1;

similar problem seems to occur using the Parameters panel

<h3>Headers</h3> <table> <thead> <tr> <th>Key</th> <th>Value</th
C:/strawberry/perl/site/lib/Text/MicroTemplate.pm
line 437

Plack/Middleware/Debug/Memory.pm: Can't exec "ps": No such file or directory

You must do NOTICE in doc about that that system 'ps' utility must be accessible through PATH when using this module

Can't exec "ps": No such file or directory at /usr/share/perl5/Plack/Middleware/Debug/Memory.pm line 37.
Use of uninitialized value $out in substitution (s///) at /usr/share/perl5/Plack/Middleware/Debug/Memory.pm line 38.
Use of uninitialized value $out in substitution (s///) at /usr/share/perl5/Plack/Middleware/Debug/Memory.pm line 38.
Argument "" isn't numeric in subtraction (-) at /usr/share/perl5/Plack/Middleware/Debug/Memory.pm line 19.
Argument "" isn't numeric in subtraction (-) at /usr/share/perl5/Plack/Middleware/Debug/Memory.pm line 19.

potential leak

problem is described in closed issue 2 (memory and objects)

the problem occurs if no body tag is returned, in this case, there seems to be a leak in persitant environment (plackup)
(in my case, i returned 404 with text/plain and no body tag)

Memory-debugging improvements

Right now, the memory debugging only looks at RSS. This isn't ideal for debugging memory leaks, since they will typically be reflected in USS numbers.

I have some code that uses Devel::Gladiator to track the changing number of reftypes. Is this something that sounds like it belongs in the base of Plack::Middleware::Debug? No worries if no, I'm happy to add it as a separate distro.

Debug Panels computed too early if c.write is used

It looks like this section of the code:

        my $content = $self->renderer->($vars);
        return sub {
            my $chunk = shift;
            return unless defined $chunk;
            $chunk =~ s!(?=</body>)!$content!i;
            return $chunk;
        };

will freeze the content of the debug panels the first time some streaming content comes back. In our app, we're using c.write to get Time-To-First-Byte down, and therefore the panels are frozen at that time, and don't contain data that would have been accumulated throughout the rendering of the page. Would it be possible to compute $content only when </body> is seen instead, so that the debug panels are computed after the full page render?

Doesn't behave well when $_[0]->{lines} is undefined

I haven't been able to fully trace the cause, but sometimes $_[0]->{lines} isn't defined and produces console errors like:

Use of uninitialized value in split at line 4 in template passed from /opt/xt/xt-perl/lib/site_perl/5.12.4/Plack/Middleware/Debug/Base.pm at line 67.
----------------------------------------------------------------------------
2:     <tbody>
3: % my $i;
4: % my @lines = ref $_[0]->{lines} eq 'ARRAY' ? @{$_[0]->{lines}} : split /\r?\n/, $_[0]->{lines};
5: % for my $line (@lines) {
6:             <tr class="<%= ++$i % 2 ? 'plDebugEven' : 'plDebugOdd' %>">
----------------------------------------------------------------------------

I've resolved this locally by modifying Base.pm:

my $line_template = __PACKAGE__->build_template(<<'EOTMPL');
<table>
    <tbody>
% my $i;
% if (defined $_[0]->{lines}) {
%   my @lines = ref $_[0]->{lines} eq 'ARRAY' ? @{$_[0]->{lines}} : split /\r?\n/, $_[0]->{lines};
%   for my $line (@lines) {
            <tr class="<%= ++$i % 2 ? 'plDebugEven' : 'plDebugOdd' %>">
                <td><%= $line %></td>
            </tr>
%   }
% }
    </tbody>
</table>
EOTMPL

I plan to fork, patch and submit a pull request shortly.

Memory leak (perl 5.8.8, linux-i386, CentOS 5.5)

I cannot install this module on perl5.8.8, due to a memory leak:

CPAN: File::HomeDir loaded ok (v0.86)
CPAN: Storable loaded ok (v2.24)
Reading '/root/.cpan/Metadata'
  Database was generated on Mon, 21 Nov 2011 12:27:23 GMT
Running install for module 'Plack::Middleware::Debug'
Running make for M/MI/MIYAGAWA/Plack-Middleware-Debug-0.14.tar.gz
CPAN: Digest::SHA loaded ok (v5.47)
CPAN: Compress::Zlib loaded ok (v1.34)
Checksum for /root/.cpan/sources/authors/id/M/MI/MIYAGAWA/Plack-Middleware-Debug-0.14.tar.gz ok
CPAN: Archive::Tar loaded ok (v1.54)
Plack-Middleware-Debug-0.14/
Plack-Middleware-Debug-0.14/Changes
Plack-Middleware-Debug-0.14/examples/
Plack-Middleware-Debug-0.14/inc/
Plack-Middleware-Debug-0.14/INSTALL
Plack-Middleware-Debug-0.14/lib/
Plack-Middleware-Debug-0.14/Makefile.PL
Plack-Middleware-Debug-0.14/MANIFEST
Plack-Middleware-Debug-0.14/META.yml
Plack-Middleware-Debug-0.14/README
Plack-Middleware-Debug-0.14/README.mkdn
Plack-Middleware-Debug-0.14/share/
Plack-Middleware-Debug-0.14/t/
Plack-Middleware-Debug-0.14/xt/
Plack-Middleware-Debug-0.14/xt/author/
Plack-Middleware-Debug-0.14/xt/author/00_compile.t
Plack-Middleware-Debug-0.14/xt/author/01_perl_critic.t
Plack-Middleware-Debug-0.14/xt/author/02_pod.t
Plack-Middleware-Debug-0.14/xt/author/03_podspell.t
Plack-Middleware-Debug-0.14/xt/author/04_pod_coverage.t
Plack-Middleware-Debug-0.14/xt/author/05_kwalitee.t
Plack-Middleware-Debug-0.14/xt/author/06_yaml_meta.t
Plack-Middleware-Debug-0.14/xt/author/07_portability_files.t
Plack-Middleware-Debug-0.14/xt/author/08_synopsis.t
Plack-Middleware-Debug-0.14/xt/author/09_minimum_version.t
Plack-Middleware-Debug-0.14/xt/author/10_has_version.t
Plack-Middleware-Debug-0.14/xt/author/11_check_changes.t
Plack-Middleware-Debug-0.14/xt/author/12_manifest.t
Plack-Middleware-Debug-0.14/xt/author/perlcriticrc
Plack-Middleware-Debug-0.14/t/01_basic.t
Plack-Middleware-Debug-0.14/t/parameters-leak.t
Plack-Middleware-Debug-0.14/t/utf8.t
Plack-Middleware-Debug-0.14/share/debug_toolbar/
Plack-Middleware-Debug-0.14/share/debug_toolbar/back.png
Plack-Middleware-Debug-0.14/share/debug_toolbar/back_hover.png
Plack-Middleware-Debug-0.14/share/debug_toolbar/close.png
Plack-Middleware-Debug-0.14/share/debug_toolbar/close_hover.png
Plack-Middleware-Debug-0.14/share/debug_toolbar/indicator.png
Plack-Middleware-Debug-0.14/share/debug_toolbar/information.gif
Plack-Middleware-Debug-0.14/share/debug_toolbar/jquery.cookie.js
Plack-Middleware-Debug-0.14/share/debug_toolbar/jquery.js
Plack-Middleware-Debug-0.14/share/debug_toolbar/panel_bg.png
Plack-Middleware-Debug-0.14/share/debug_toolbar/toolbar.css
Plack-Middleware-Debug-0.14/share/debug_toolbar/toolbar.js
Plack-Middleware-Debug-0.14/share/debug_toolbar/toolbar.min.css
Plack-Middleware-Debug-0.14/share/debug_toolbar/toolbar.min.js
Plack-Middleware-Debug-0.14/lib/Plack/
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/Base.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/CatalystLog.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/DBITrace.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/Environment.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/Memory.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/ModuleVersions.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/Panel.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/Parameters.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/PerlConfig.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/Response.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/Session.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/Timer.pm
Plack-Middleware-Debug-0.14/lib/Plack/Middleware/Debug/TrackObjects.pm
Plack-Middleware-Debug-0.14/inc/Module/
Plack-Middleware-Debug-0.14/inc/Module/AutoInstall.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/
Plack-Middleware-Debug-0.14/inc/Module/Install.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/AutoInstall.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Base.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Can.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Fetch.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Include.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Makefile.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Metadata.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/ReadmeFromPod.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Repository.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Share.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/Win32.pm
Plack-Middleware-Debug-0.14/inc/Module/Install/WriteAll.pm
Plack-Middleware-Debug-0.14/examples/dbi/
Plack-Middleware-Debug-0.14/examples/hello-world/
Plack-Middleware-Debug-0.14/examples/hello-world/app.psgi
Plack-Middleware-Debug-0.14/examples/dbi/app.psgi
Plack-Middleware-Debug-0.14/examples/dbi/dump.sql
Plack-Middleware-Debug-0.14/examples/dbi/foo.db
/bin/tar: Read 3584 bytes from -
CPAN: File::Temp loaded ok (v0.22)
CPAN: Parse::CPAN::Meta loaded ok (v1.4401)
CPAN: CPAN::Meta loaded ok (v2.110930)
CPAN: Module::CoreList loaded ok (v2.49)

  CPAN.pm: Building M/MI/MIYAGAWA/Plack-Middleware-Debug-0.14.tar.gz

*** Module::AutoInstall version 1.03
*** Checking for Perl dependencies...
*** Since we're running under CPAN, I'll just let it take care
    of the dependency's installation later.
[Core Features]
- Test::More               ...loaded. (0.96 >= 0.70)
- ExtUtils::MakeMaker      ...loaded. (6.59 >= 6.11)
- parent                   ...loaded. (0.223)
- Plack                    ...loaded. (0.9984)
- Text::MicroTemplate      ...loaded. (0.18 >= 0.15)
- Data::Dump               ...loaded. (1.15)
- File::ShareDir           ...loaded. (1.03 >= 1.00)
- Class::Method::Modifiers ...loaded. (1.06 >= 1.05)
- Encode                   ...loaded. (2.33 >= 2.23)
[Module versions panel]
- Module::Versions         ...loaded. (0.02 >= 0.01)
*** Module::AutoInstall configuration finished.
Checking if your kit is complete...
Looks good
Writing Makefile for Plack::Middleware::Debug
Could not read metadata file. Falling back to other methods to determine prerequisites
cp lib/Plack/Middleware/Debug/TrackObjects.pm blib/lib/Plack/Middleware/Debug/TrackObjects.pm
cp lib/Plack/Middleware/Debug/Parameters.pm blib/lib/Plack/Middleware/Debug/Parameters.pm
cp lib/Plack/Middleware/Debug/ModuleVersions.pm blib/lib/Plack/Middleware/Debug/ModuleVersions.pm
cp lib/Plack/Middleware/Debug/CatalystLog.pm blib/lib/Plack/Middleware/Debug/CatalystLog.pm
cp lib/Plack/Middleware/Debug/Session.pm blib/lib/Plack/Middleware/Debug/Session.pm
cp lib/Plack/Middleware/Debug/Panel.pm blib/lib/Plack/Middleware/Debug/Panel.pm
cp lib/Plack/Middleware/Debug.pm blib/lib/Plack/Middleware/Debug.pm
cp lib/Plack/Middleware/Debug/Timer.pm blib/lib/Plack/Middleware/Debug/Timer.pm
cp lib/Plack/Middleware/Debug/Memory.pm blib/lib/Plack/Middleware/Debug/Memory.pm
cp lib/Plack/Middleware/Debug/DBITrace.pm blib/lib/Plack/Middleware/Debug/DBITrace.pm
cp lib/Plack/Middleware/Debug/PerlConfig.pm blib/lib/Plack/Middleware/Debug/PerlConfig.pm
cp lib/Plack/Middleware/Debug/Base.pm blib/lib/Plack/Middleware/Debug/Base.pm
cp lib/Plack/Middleware/Debug/Environment.pm blib/lib/Plack/Middleware/Debug/Environment.pm
cp lib/Plack/Middleware/Debug/Response.pm blib/lib/Plack/Middleware/Debug/Response.pm
Manifying blib/man3/Plack::Middleware::Debug::TrackObjects.3pm
Manifying blib/man3/Plack::Middleware::Debug::Parameters.3pm
Manifying blib/man3/Plack::Middleware::Debug::ModuleVersions.3pm
Manifying blib/man3/Plack::Middleware::Debug::Session.3pm
Manifying blib/man3/Plack::Middleware::Debug::CatalystLog.3pm
Manifying blib/man3/Plack::Middleware::Debug.3pm
Manifying blib/man3/Plack::Middleware::Debug::Timer.3pm
Manifying blib/man3/Plack::Middleware::Debug::DBITrace.3pm
Manifying blib/man3/Plack::Middleware::Debug::Memory.3pm
Manifying blib/man3/Plack::Middleware::Debug::Base.3pm
Manifying blib/man3/Plack::Middleware::Debug::PerlConfig.3pm
Manifying blib/man3/Plack::Middleware::Debug::Environment.3pm
Manifying blib/man3/Plack::Middleware::Debug::Response.3pm
  MIYAGAWA/Plack-Middleware-Debug-0.14.tar.gz
  /usr/bin/make -- OK
CPAN: YAML loaded ok (v0.72)
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/01_basic.t t/parameters-leak.t t/utf8.t
t/01_basic.t ......... ok

#   Failed test 'No leaks in application (leaks 8 == 0)'
#   at t/parameters-leak.t line 41.
#          got: 8
#     expected: 0
# leaked SCALAR(0x8899968) from /usr/lib/perl5/site_perl/5.8.8/Plack/Request.pm line 86.
#   85:    my $self = shift;
#   86:    $self->env->{'plack.request.query'} ||= Hash::MultiValue->new($self->uri->query_form);
#   87:}
# SV = IV(0x84fbbb8) at 0x8899968
#   REFCNT = 1
#   FLAGS = (IOK,pIOK)
#   IV = 141665604
# leaked SCALAR(0x88eb58c) from /usr/lib/perl5/site_perl/5.8.8/URI.pm line 64.
#   63:
#   64:    return $impclass->_init($uri, $scheme);
#   65:}
# SV = IV(0x888f0e0) at 0x88eb58c
#   REFCNT = 1
#   FLAGS = (IOK,pIOK)
#   IV = 143388156
# leaked SCALAR(0x88f4320) from /root/.cpan/build/Plack-Middleware-Debug-0.14-xwQMq7/blib/lib/Plack/Middleware/Debug/Base.pm line 47.
#   46:
#   47:    my $panel = Plack::Middleware::Debug::Panel->new;
#   48:    $panel->dom_id("plDebug${id}Panel");
# SV = IV(0x888ef14) at 0x88f4320
#   REFCNT = 1
#   FLAGS = (IOK,pIOK)
#   IV = 141015428
# leaked SCALAR(0x88f4260) from /usr/lib/perl5/site_perl/5.8.8/Plack/Request.pm line 117.
#  116:            }
#  117:                grep { /^(?:HTTP|CONTENT|COOKIE)/i } keys %$env
#  118:            );
# SV = IV(0x888edc0) at 0x88f4260
#   REFCNT = 1
#   FLAGS = (IOK,pIOK)
#   IV = 138612472
# leaked SCALAR(0x88f3f0c) from /usr/lib/perl5/site_perl/5.8.8/Text/MicroTemplate.pm line 327.
#  326:sub encoded_string {
#  327:    Text::MicroTemplate::EncodedString->new($_[0]);
#  328:}
# SV = IV(0x86e4f98) at 0x88f3f0c
#   REFCNT = 1
#   FLAGS = (IOK,pIOK)
#   IV = 141260364
# leaked SCALAR(0x88f3d68) from /usr/lib/perl5/site_perl/5.8.8/Plack/Test/MockHTTP.pm line 24.
#   23:        my $res = try {
#   24:            HTTP::Response->from_psgi($app->($env));
#   25:        } catch {
# SV = IV(0x888f0e4) at 0x88f3d68
#   REFCNT = 1
#   FLAGS = (IOK,pIOK)
#   IV = 139029260
# leaked SCALAR(0x88f3ca8) from /usr/lib/perl5/site_perl/5.8.8/Plack/Request.pm line 226.
#  225:
#  226:    return URI->new($base . $path)->canonical;
#  227:}
# SV = IV(0x86e5104) at 0x88f3ca8
#   REFCNT = 1
#   FLAGS = (IOK,pIOK)
#   IV = 138680420
# leaked SCALAR(0x88f3834) from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Encode.pm line 127.
#  126:    my ( $name, $skip_external ) = @_;
#  127:    return __PACKAGE__->getEncoding( $name, $skip_external );
#  128:}
# SV = IV(0x888f0d0) at 0x88f3834
#   REFCNT = 1
#   FLAGS = (IOK,pIOK)
#   IV = 138870508
# Looks like you failed 1 test of 4.
t/parameters-leak.t .. 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/4 subtests 
t/utf8.t ............. ok

Test Summary Report
-------------------
t/parameters-leak.t (Wstat: 256 Tests: 4 Failed: 1)
  Failed test:  4
  Non-zero exit status: 1
Files=3, Tests=17,  7 wallclock secs ( 0.04 usr  0.01 sys +  6.64 cusr  0.12 csys =  6.81 CPU)
Result: FAIL
Failed 1/3 test programs. 1/17 subtests failed.
make: *** [test_dynamic] Error 255
  MIYAGAWA/Plack-Middleware-Debug-0.14.tar.gz
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports MIYAGAWA/Plack-Middleware-Debug-0.14.tar.gz
Running make install
  make test had returned bad status, won't install without force

Allow scrolling for panel

If I have use many panels, they goes out of the screen
These two screen shots of same page. Just browser window were resized

debug-panel-bug2
debug-panel-bug

Collect data between redirects

The problem I have run into with Plack::Middleware::Debug::Log4perl

The log messages are not displayed that were logged while processing POST data, when I POST to page that redirect (302) back to page with this form
When redirect occours the collected data in DebugPanel must be saved somewhere (maybe in session???) and displayed them on redirecting page.

But this is applyed also to 'Request variables', 'Response', 'Environment', 'Memory', 'Timer', etc.
They must show values for those two requests

  1. POST. When I try to save form
  2. GET. When form is saved and result page is showed

memory leak using dbitrace and Parameters panel

I have started to use dbi module now and the dbi trace information is displayed correctly.

However, there seems to be another leak.

Track objects indicates that more and more of these entries reside in memory:

<table> <tbody> <tr class="plDebugEven"> <td> DBI 1.613-ithread d.......
C:/strawberry/perl/site/lib/Text/MicroTemplate.pm
line 437

using the following code:

in my_app.psgi, I use

sub import {
    use Devel::TrackObjects qr/^/;
}

Then

builder {
enable 'Debug', panels =>
[ qw(Environment Response Timer WindowsMemory Session TrackObjects),
[ 'DBITrace', level => 2 ]
];
and in TrackObjects:

package Plack::Middleware::Debug::TrackObjects;

use parent qw(Plack::Middleware::Debug::Base);

sub run {
    my($self, $env, $panel) = @_;

    return sub {
        my $res = shift;

        my $track = Devel::TrackObjects->show_tracked_detailed;
        my @content;

        foreach (@$track){
            if (length($_->[0]) > 100){
                $_->[0] = substr($_->[0],$i,100);
            }
            push @content, $_->[0], $_->[1].' - '.$_->[2];
        }

        $panel->nav_subtitle('Number:'.scalar(@content)/2);

        $panel->content(
            $self->render_list_pairs([@content])
        );
    };

}

1;

similar problem seems to occur using the Parameters panel

<h3>Headers</h3> <table> <thead> <tr> <th>Key</th> <th>Value</th
C:/strawberry/perl/site/lib/Text/MicroTemplate.pm
line 437

memory and objects

not sure whether this is a bug, please ignore if it doesn't make sense:

in my_app.psgi, I use
sub import {
use Devel::TrackObjects qr/^/;
}

Then

builder {
    enable 'Debug', panels =>
      [ qw(Environment Response Timer WindowsMemory Session TrackObjects),
        [ 'DBITrace', level => 2 ]
      ];

and in TrackObjects:

package Plack::Middleware::Debug::TrackObjects;

use parent qw(Plack::Middleware::Debug::Base);

sub run {
    my($self, $env, $panel) = @_;

    return sub {
        my $res = shift;

        my $track = Devel::TrackObjects->show_tracked_detailed;
        my @content;

        foreach (@$track){
            if (length($_->[0]) > 100){
                $_->[0] = substr($_->[0],$i,100);
            }
            push @content, $_->[0], $_->[1].' - '.$_->[2];
        }

        $panel->nav_subtitle('Number:'.scalar(@content)/2);

        $panel->content(
            $self->render_list_pairs([@content])
        );
    };

}

1;

the number of objects is growing, memory as well:

Track objects indicates that more and more of these entries reside in memory:
Plack::Middleware::Debug::Panel=HASH(0x2eeed44) C:/strawberry/perl/site/lib/Plack/Middleware/Debug/Panel.pm - 6
Plack::Middleware::Debug::Panel=HASH(0x2eeed64) C:/strawberry/perl/site/lib/Plack/Middleware/Debug/Panel.pm - 6
Plack::Middleware::Debug::Panel=HASH(0x2eee494) C:/strawberry/perl/site/lib/Plack/Middleware/Debug/Panel.pm - 6

C:/strawberry/perl/site/lib/Text/MicroTemplate.pm - 437
Key Value
C:/strawberry/perl/site/lib/Text/MicroTemplate.pm - 437
Key Value
C:/strawberry/perl/site/lib/Text/MicroTemplate.pm - 437
Key Value
C:/strawberry/perl/site/lib/Text/MicroTemplate.pm - 437

Key Value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.