| 1 | package Sledge::Plugin::DebugMessage; | ||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | our $VERSION = '0.04'; | |||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use Jcode; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use Template; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | our $LOG_SIZE = 20; | |||||||||||||||||||
| 11 | 1 | our $TEMPLATE = <<'EOF'; | |||||||||||||||||||
| 12 | <div style="font-weight:bold;background-color:#ffccff;text-align:left;left-margin:3px"> | ||||||||||||||||||||
| 13 | <h2>debug message</h2> | ||||||||||||||||||||
| 14 | <div style="color:red"> | ||||||||||||||||||||
| 15 | [%- FOR v IN pages.session.param('_debug_msg') %] | ||||||||||||||||||||
| 16 | [% v.replace("\n", "") | html %]<br /> | ||||||||||||||||||||
| 17 | [%- END %] | ||||||||||||||||||||
| 18 | </div> | ||||||||||||||||||||
| 19 | <h2>tmpl</h2> | ||||||||||||||||||||
| 20 | <table style="color:green;text-align:left"> | ||||||||||||||||||||
| 21 | [%- FOR v IN pages.tmpl.param() %] | ||||||||||||||||||||
| 22 | <tr><th>[% v | html %]</th><td>[% pages.tmpl.param(v) | html %]</td></tr> | ||||||||||||||||||||
| 23 | [%- END %] | ||||||||||||||||||||
| 24 | </table> | ||||||||||||||||||||
| 25 | <h2>r</h2> | ||||||||||||||||||||
| 26 | <table style="color:magenta;text-align:left"> | ||||||||||||||||||||
| 27 | [%- FOR v IN pages.r.param() %] | ||||||||||||||||||||
| 28 | <tr><th>[% v | html %]</th><td>[% pages.r.param(v) | html %]</td></tr> | ||||||||||||||||||||
| 29 | [%- END %] | ||||||||||||||||||||
| 30 | </table> | ||||||||||||||||||||
| 31 | <h2>session</h2> | ||||||||||||||||||||
| 32 | <table style="color:blue;text-align:left"> | ||||||||||||||||||||
| 33 | [%- FOR v IN pages.session.param() %] | ||||||||||||||||||||
| 34 | <tr><th>[% v | html %]</th><td>[% pages.session.param(v) | html %]</td></tr> | ||||||||||||||||||||
| 35 | [%- END %] | ||||||||||||||||||||
| 36 | </table> | ||||||||||||||||||||
| 37 | <h2>last_mail</h2> | ||||||||||||||||||||
| 38 | <pre>[% last_mail | html %]</pre> | ||||||||||||||||||||
| 39 | </div></body> | ||||||||||||||||||||
| 40 | EOF | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 1 | ▶ | sub import { | ||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.8
| |||||||||||||||||||||
| 43 | 1 | my $class = shift; | |||||||||||||||||||
| 44 | 1 | my $pkg = caller; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | ▶ | $pkg->register_hook(BEFORE_OUTPUT => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||||||||
| 48 | 0 | ▶ | if ($self->debug_level) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | 0 | ▶ | $self->add_filter(sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 50 | 0 | $class->_debug_message_filter(@_); | |||||||||||||||||||
| 51 | 0 | }); | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | 1 | }); | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 56 | 1 | *{"$pkg\::debug"} = \&debug; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | ▶ | sub debug { | ||||||||||||||||||
|
Subroutine
debug: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 60 | 0 | my $self = shift; | |||||||||||||||||||
| 61 | 0 | my $msg = shift; | |||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 0 | ▶ | if ($self->debug_level) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 0 | my ($package, $filename, $line) = caller(0); | |||||||||||||||||||
| 65 | 0 | ▶ | my $page = $self->page || 'index'; | ||||||||||||||||||
|
Condition0%0/2
$self->page || 'index'
MC/DC0%0/1
$self->page || 'index'
$self->page
Truth table0%0/2
A
A= $self->page
| |||||||||||||||||||||
| 66 | 0 | my $dumped = Dumper(@_); | |||||||||||||||||||
| 67 | 0 | my $dbg_line = "$page, $package($line) : $msg : $dumped"; | |||||||||||||||||||
| 68 | 0 | ▶ | if ($self->session) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 69 | $self->session->param( | ||||||||||||||||||||
| 70 | '_debug_msg' => [( | ||||||||||||||||||||
| 71 | $dbg_line, | ||||||||||||||||||||
| 72 | 0 | ▶ | @{$self->session->param('_debug_msg') || []}, | ||||||||||||||||||
|
Condition0%0/2
$self->session->param('_debug_msg') || []
MC/DC0%0/1
$self->session->param('_debug_msg') || []
$self->session->param('_debug_msg')
Truth table0%0/2
A
A= $self->session->param('_debug_msg')
| |||||||||||||||||||||
| 73 | )[0..$LOG_SIZE]] | ||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 0 | ▶ | sub _debug_message_filter { | ||||||||||||||||||
|
Subroutine
_debug_message_filter: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 80 | 0 | my ($self, $pages, $content) = @_; | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | ▶ | my $last_mail = $pages->session ? Jcode->new($pages->session->param('last_mail') || '', 'jis')->euc : ''; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$pages->session->param('last_mail') || ''
MC/DC0%0/1
$pages->session->param('last_mail') || ''
$pages->session->param('last_mail')
Truth table0%0/2
A
A= $pages->session->param('last_mail')
| |||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 0 | my $tt = Template->new; | |||||||||||||||||||
| 85 | 0 | $tt->process(\$TEMPLATE, {pages => $pages, last_mail => $last_mail}, \my $out); | |||||||||||||||||||
| 86 | 0 | $content =~ s{</body>}{$out}; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | return $content; | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 1 | 1; | |||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||