Coverage Summary
File Coverage
blib/lib/Sledge/Plugin/DebugMessage.pm |
|
Criterion |
Covered |
Total |
% |
statement |
23 |
43 |
53.4
|
branch |
0 |
10 |
0.0
|
condition |
0 |
4 |
0.0
|
subroutine |
7 |
10 |
70.0
|
pod |
1 |
1 |
100.0
|
total |
31 |
68 |
45.5
|
line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sledge::Plugin::DebugMessage; |
2
|
1
|
|
|
1
|
|
33969
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
2224
|
use Jcode; |
|
1
|
|
|
|
|
63376
|
|
|
1
|
|
|
|
|
194
|
|
7
|
1
|
|
|
1
|
|
2104
|
use Data::Dumper; |
|
1
|
|
|
|
|
10110
|
|
|
1
|
|
|
|
|
89
|
|
8
|
1
|
|
|
1
|
|
1791
|
use Template; |
|
1
|
|
|
|
|
26604
|
|
|
1
|
|
|
|
|
134
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $LOG_SIZE = 20; |
11
|
|
|
|
|
|
|
our $TEMPLATE = <<'EOF'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
debug message |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
[%- FOR v IN pages.session.param('_debug_msg') %] |
16
|
|
|
|
|
|
|
[% v.replace("\n", "") | html %] |
17
|
|
|
|
|
|
|
[%- END %] |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
tmpl |
20
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
[%- FOR v IN pages.tmpl.param() %] |
22
|
|
|
|
|
|
|
| [% v | html %] | [% pages.tmpl.param(v) | html %] |
23
|
|
|
|
|
|
|
[%- END %] |
24
|
|
|
|
|
|
|
| |
25
|
|
|
|
|
|
|
r |
26
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
[%- FOR v IN pages.r.param() %] |
28
|
|
|
|
|
|
|
| [% v | html %] | [% pages.r.param(v) | html %] |
29
|
|
|
|
|
|
|
[%- END %] |
30
|
|
|
|
|
|
|
| |
31
|
|
|
|
|
|
|
session |
32
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
[%- FOR v IN pages.session.param() %] |
34
|
|
|
|
|
|
|
| [% v | html %] | [% pages.session.param(v) | html %] |
35
|
|
|
|
|
|
|
[%- END %] |
36
|
|
|
|
|
|
|
| |
37
|
|
|
|
|
|
|
last_mail |
38
|
|
|
|
|
|
|
[% last_mail | html %] |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
EOF |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub import { |
43
|
1
|
|
|
1
|
|
12
|
my $class = shift; |
44
|
1
|
|
|
|
|
2
|
my $pkg = caller; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$pkg->register_hook(BEFORE_OUTPUT => sub { |
47
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
48
|
0
|
0
|
|
|
|
0
|
if ($self->debug_level) { |
49
|
|
|
|
|
|
|
$self->add_filter(sub { |
50
|
0
|
|
|
|
|
0
|
$class->_debug_message_filter(@_); |
51
|
0
|
|
|
|
|
0
|
}); |
52
|
|
|
|
|
|
|
} |
53
|
1
|
|
|
|
|
10
|
}); |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
22
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
513
|
|
56
|
1
|
|
|
|
|
5
|
*{"$pkg\::debug"} = \&debug; |
|
1
|
|
|
|
|
16
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub debug { |
60
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my $msg = shift; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ($self->debug_level) { |
64
|
0
|
|
|
|
|
|
my ($package, $filename, $line) = caller(0); |
65
|
0
|
|
0
|
|
|
|
my $page = $self->page || 'index'; |
66
|
0
|
|
|
|
|
|
my $dumped = Dumper(@_); |
67
|
0
|
|
|
|
|
|
my $dbg_line = "$page, $package($line) : $msg : $dumped"; |
68
|
0
|
0
|
|
|
|
|
if ($self->session) { |
69
|
0
|
0
|
|
|
|
|
$self->session->param( |
70
|
|
|
|
|
|
|
'_debug_msg' => [( |
71
|
|
|
|
|
|
|
$dbg_line, |
72
|
0
|
|
|
|
|
|
@{$self->session->param('_debug_msg') || []}, |
73
|
|
|
|
|
|
|
)[0..$LOG_SIZE]] |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _debug_message_filter { |
80
|
0
|
|
|
0
|
|
|
my ($self, $pages, $content) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
0
|
|
|
|
my $last_mail = $pages->session ? Jcode->new($pages->session->param('last_mail') || '', 'jis')->euc : ''; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $tt = Template->new; |
85
|
0
|
|
|
|
|
|
$tt->process(\$TEMPLATE, {pages => $pages, last_mail => $last_mail}, \my $out); |
86
|
0
|
|
|
|
|
|
$content =~ s{}{$out}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $content; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
__END__ |