line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Debugbar; |
2
|
1
|
|
|
1
|
|
53616
|
use Mojo::Base -base; |
|
1
|
|
|
|
|
198963
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
534
|
use Mojo::Debugbar::Monitors; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
383
|
use Mojo::Loader qw(load_class); |
|
1
|
|
|
|
|
41312
|
|
|
1
|
|
|
|
|
51
|
|
6
|
1
|
|
|
1
|
|
375
|
use Mojo::Server; |
|
1
|
|
|
|
|
7614
|
|
|
1
|
|
|
|
|
13
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.0.4'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'app' => sub { Mojo::Server->new->build_app('Mojo::HelloWorld') }, weak => 1; |
11
|
|
|
|
|
|
|
has 'config' => sub {{ |
12
|
|
|
|
|
|
|
hide_empty => 0, |
13
|
|
|
|
|
|
|
monitors => [ |
14
|
|
|
|
|
|
|
'Mojo::Debugbar::Monitor::Request', |
15
|
|
|
|
|
|
|
'Mojo::Debugbar::Monitor::DBIx', |
16
|
|
|
|
|
|
|
'Mojo::Debugbar::Monitor::Template', |
17
|
|
|
|
|
|
|
'Mojo::Debugbar::Monitor::ValidationTiny', |
18
|
|
|
|
|
|
|
], |
19
|
|
|
|
|
|
|
}}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'monitors' => sub { |
22
|
|
|
|
|
|
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my @monitors; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
foreach my $module (@{ $self->config->{ monitors } || [] }) { |
27
|
|
|
|
|
|
|
my $monitor = _monitor($module, 1); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
push(@monitors, $monitor->new(app => $self->app)); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return Mojo::Debugbar::Monitors->new( |
33
|
|
|
|
|
|
|
registered => \@monitors, |
34
|
|
|
|
|
|
|
hide_empty => $self->config->{ hide_empty }, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 render |
39
|
|
|
|
|
|
|
Proxy for monitors->render |
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub render { |
43
|
0
|
|
|
0
|
1
|
|
return shift->monitors->render; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 stop |
47
|
|
|
|
|
|
|
Proxy for monitors->stop |
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub stop { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->monitors->stop; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 start |
59
|
|
|
|
|
|
|
Proxy for monitors->start |
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub start { |
63
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->monitors->start; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return $self; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 _monitor |
72
|
|
|
|
|
|
|
Load monitor |
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _monitor { |
76
|
0
|
|
|
0
|
|
|
my ($module, $fatal) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
return $module->isa('Mojo::Debugbar::Monitor') ? $module : undef |
|
|
0
|
|
|
|
|
|
79
|
|
|
|
|
|
|
unless my $e = load_class $module; |
80
|
0
|
0
|
0
|
|
|
|
$fatal && ref $e ? die $e : return undef; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding utf8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Mojo::Debugbar - A nice Debugbar that helps developers using Mojolicious framework |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SYNOPSIS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
use Mojo::Debugbar; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $debugbar = Mojo::Debugbar->new(app => $app, config => { |
96
|
|
|
|
|
|
|
hide_empty => 0, |
97
|
|
|
|
|
|
|
monitors => [ |
98
|
|
|
|
|
|
|
'Mojo::Debugbar::Monitor::Request', |
99
|
|
|
|
|
|
|
'Mojo::Debugbar::Monitor::DBIx', |
100
|
|
|
|
|
|
|
'Mojo::Debugbar::Monitor::Template', |
101
|
|
|
|
|
|
|
'Mojo::Debugbar::Monitor::ValidationTiny', |
102
|
|
|
|
|
|
|
] |
103
|
|
|
|
|
|
|
}); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$debugbar->start; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
... |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
$debugbar->stop; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DESCRIPTION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L is a package that helps you collect some metrics for your Mojolicious app |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L inherits all attributes from L. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 METHODS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L inherits all methods from L and implements |
122
|
|
|
|
|
|
|
the following new ones. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 render |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$debugbar->start; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Renders the collected metrics as html. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 start |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$debugbar->start; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Starts all the monitors. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 stop |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
$debugbar->stop; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Stops all the monitors. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SEE ALSO |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L, L, L, L. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |