| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Egg::Util::Debug; |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# $Id: Debug.pm 337 2008-05-14 12:30:09Z lushe $ |
|
6
|
|
|
|
|
|
|
# |
|
7
|
1
|
|
|
1
|
|
444
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
37
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
127
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION= '3.01'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _setup { |
|
13
|
0
|
|
|
0
|
|
|
my($class, $e, $p)= @_; |
|
14
|
0
|
|
|
|
|
|
$e->_setup_log($p); |
|
15
|
0
|
|
0
|
|
|
|
my $benchmark= |
|
16
|
|
|
|
|
|
|
$ENV{EGG_BENCH_CLASS} || 'Egg::Util::BenchMark'; |
|
17
|
0
|
|
0
|
|
|
|
my $dbgscreen= |
|
18
|
|
|
|
|
|
|
$ENV{EGG_DEBUG_SCREEN_CLASS} || 'Egg::Util::DebugScreen'; |
|
19
|
0
|
0
|
|
|
|
|
$benchmark->require or die $@; |
|
20
|
0
|
0
|
|
|
|
|
$dbgscreen->require or die $@; |
|
21
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; ## no critic. |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
22
|
1
|
|
|
1
|
|
5
|
no warnings 'redefine'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1247
|
|
|
23
|
0
|
|
|
|
|
|
*{"${p}::_start_engine"}= \&_start_engine_debug; |
|
|
0
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
*{"${p}::debug_screen"} = $dbgscreen->can('_debug_screen'); |
|
|
0
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
*{"${p}::debug_out"} = \&_debug_out; |
|
|
0
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
*{"${p}::debug_end"} = \&_debug_end; |
|
|
0
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
*{"${p}::egg_warn"} = \&_egg_warn; |
|
|
0
|
|
|
|
|
|
|
|
28
|
0
|
|
|
0
|
|
|
*{"${p}::bench"} = sub { shift->{benchmark}->stock(@_) }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $plugins= $e->regists; |
|
30
|
0
|
|
|
|
|
|
my $r_class= $e->global->{request_class}; |
|
31
|
0
|
|
|
|
|
|
$e->debug_out(<<END_INFO); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# ---------------------------------------------------------- |
|
34
|
|
|
|
|
|
|
# >> Egg - ${p}: startup !! - load plugins. |
|
35
|
0
|
|
0
|
|
|
|
# @{[ |
|
36
|
0
|
|
0
|
|
|
|
join("\n# ", map{"= $_->[0] v$_->[1]"}values %$plugins) || "...none." |
|
37
|
|
|
|
|
|
|
]} |
|
38
|
|
|
|
|
|
|
# + Request Class: $r_class v@{[ $r_class->VERSION || 0 ]} |
|
39
|
|
|
|
|
|
|
END_INFO |
|
40
|
|
|
|
|
|
|
sub { |
|
41
|
0
|
|
|
0
|
|
|
my($egg)= @_; |
|
42
|
0
|
|
|
|
|
|
$egg->debug_out(<<END_REPORT); |
|
43
|
0
|
|
0
|
|
|
|
# >>>>> $egg->{namespace} v@{[ $egg->VERSION || 0.00 ]} |
|
44
|
|
|
|
|
|
|
END_REPORT |
|
45
|
0
|
|
|
|
|
|
$egg->{benchmark}= $benchmark->new(@_); |
|
46
|
0
|
|
|
|
|
|
}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
sub _start_engine_debug { |
|
49
|
0
|
|
|
0
|
|
|
my($e)= @_; |
|
50
|
0
|
|
|
0
|
|
|
local $SIG{__DIE__}= sub { Egg::Error->throw(@_) }; |
|
|
0
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$e->_prepare; $e->bench('prepare'); |
|
|
0
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$e->_dispatch; $e->bench('dispatch'); |
|
|
0
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$e->_action_start; $e->bench('action_start'); |
|
|
0
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$e->_action_end; $e->bench('action_end'); |
|
|
0
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$e->_finalize; $e->bench('finalize'); |
|
|
0
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$e->_output; $e->bench('output'); |
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$e->_finish; $e->bench('finish'); |
|
|
0
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$e->{benchmark}->finish; |
|
59
|
0
|
0
|
|
|
|
|
if (my $header= $e->response->{header}) { $e->debug_out($header) } |
|
|
0
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
_debug_end($e); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
sub _debug_out { |
|
63
|
0
|
|
|
0
|
|
|
my $e = shift; |
|
64
|
0
|
|
0
|
|
|
|
my $msg= shift || return 0; |
|
65
|
0
|
0
|
|
|
|
|
$msg.= "\n" unless $msg=~m{\n$}; |
|
66
|
0
|
|
|
|
|
|
$e->{debug_buffer}.= $msg; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
sub _debug_end { |
|
69
|
0
|
|
|
0
|
|
|
my $e= shift; |
|
70
|
0
|
|
0
|
|
|
|
$e->{debug_buffer}.= shift || ""; |
|
71
|
0
|
|
|
|
|
|
$e->log->debug($e->{debug_buffer}); |
|
72
|
0
|
|
|
|
|
|
$e; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
sub _report { |
|
75
|
0
|
|
|
0
|
|
|
my($e)= @_; |
|
76
|
0
|
|
|
|
|
|
my $m= $e->model_manager->regists; |
|
77
|
0
|
|
|
|
|
|
my $v= $e->view_manager->regists; |
|
78
|
0
|
|
|
|
|
|
my $d= $e->global->{dispatch_class}; |
|
79
|
0
|
|
|
|
|
|
$e->debug_out(<<END_REPORT); |
|
80
|
0
|
|
|
|
|
|
# + Load Model: @{[ join ', ', map{"$_-$m->{$_}[1]"}keys %$m ]} |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
# + Load View : @{[ join ', ', map{"$_-$v->{$_}[1]"}keys %$v ]} |
|
|
0
|
|
|
|
|
|
|
|
82
|
0
|
|
0
|
|
|
|
@{[ $d ? "# + Load Dispatch: $d v@{[ $d->VERSION || '0.01' ]}": "" ]} |
|
83
|
|
|
|
|
|
|
END_REPORT |
|
84
|
0
|
|
|
|
|
|
$e->log->debug($e->{debug_buffer}); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
sub _egg_warn { |
|
87
|
0
|
|
|
0
|
|
|
my $e= shift; |
|
88
|
0
|
0
|
|
|
|
|
return $e->stash->{egg_warn} unless @_; |
|
89
|
0
|
0
|
|
|
|
|
my $msg= $_[0] ? do { |
|
90
|
0
|
|
|
|
|
|
ref($_[0]) eq 'HASH' |
|
91
|
0
|
|
|
|
|
|
? join "<br>\n---<br>\n", map{"$_ = $_[0]->{$_}"}keys %{$_[0]} |
|
|
0
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
: ref($_[0]) eq 'ARRAY' |
|
93
|
0
|
0
|
|
|
|
|
? join "<br>\n---<br>\n", @{$_[0]} |
|
|
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
: $_[0]; |
|
95
|
|
|
|
|
|
|
}: 'N/A'; |
|
96
|
0
|
0
|
|
|
|
|
$e->stash->{egg_warn}= $e->stash->{egg_warn} |
|
97
|
|
|
|
|
|
|
? $e->stash->{egg_warn}."<hr size=1>$msg": $msg; |
|
98
|
0
|
|
|
|
|
|
$msg; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 NAME |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Egg::Util::Debug - Debug class for Egg. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
It is a class applied when the project operates by Debaccmord. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The following methods are set up by this module for debugging. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * new |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Constructor of project. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * bench |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Easy bench mark. |
|
124
|
|
|
|
|
|
|
When the module used is changed, EGG_BENCH_CLASS of the environment variable is set. |
|
125
|
|
|
|
|
|
|
L<Egg::Util::BenchMark> is used in default. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * debug_out |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Output of debugging message. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * debug_screen |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Contents output when exception makes an error. |
|
134
|
|
|
|
|
|
|
When L<Egg::Util::DebugScreen> loaded by default is changed, |
|
135
|
|
|
|
|
|
|
EGG_DEBUG_SCREEN_CLASS of the environment variable is set. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * _start_engine |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Engine method for debugging. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L<Egg::Release>, |
|
146
|
|
|
|
|
|
|
L<Egg::Util::BenchMark>, |
|
147
|
|
|
|
|
|
|
L<Egg::Util::DebugScreen>, |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
158
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
|
159
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
|
162
|
|
|
|
|
|
|
|