line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Amon2::Plugin::Web::ChromeLogger; |
2
|
1
|
|
|
1
|
|
25256
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
1089
|
use Web::ChromeLogger; |
|
1
|
|
|
|
|
14178
|
|
|
1
|
|
|
|
|
258
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub init { |
9
|
0
|
|
|
0
|
1
|
|
my ($class, $c, $conf) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
|
return if $conf->{disabled}; |
12
|
|
|
|
|
|
|
|
13
|
0
|
0
|
0
|
|
|
|
return if $ENV{PLACK_ENV} && $ENV{PLACK_ENV} eq 'production' |
|
|
|
0
|
|
|
|
|
14
|
|
|
|
|
|
|
&& !$conf->{enable_in_production}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$c->add_trigger('BEFORE_DISPATCH' => sub { |
17
|
0
|
|
|
0
|
|
|
$_[0]->{chrome_logger} = Web::ChromeLogger->new( |
18
|
|
|
|
|
|
|
json_encoder => $conf->{json_encoder}, |
19
|
|
|
|
|
|
|
); |
20
|
0
|
|
|
|
|
|
}); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$c->add_trigger('AFTER_DISPATCH' => sub { |
23
|
0
|
|
|
0
|
|
|
$_[1]->header('X-ChromeLogger-Data' => $_[0]->{chrome_logger}->finalize); |
24
|
0
|
|
|
|
|
|
}); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Amon2::Util::add_method( |
27
|
|
|
|
|
|
|
$c => 'chrome_logger', |
28
|
|
|
|
|
|
|
sub { |
29
|
0
|
|
|
0
|
|
|
$_[0]->{chrome_logger}; |
30
|
|
|
|
|
|
|
}, |
31
|
0
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Amon2::Util::add_method( |
34
|
|
|
|
|
|
|
$c => 'chrome', |
35
|
|
|
|
|
|
|
sub { |
36
|
0
|
|
|
0
|
|
|
$_[0]->{chrome_logger}->info($_[1]); |
37
|
|
|
|
|
|
|
}, |
38
|
0
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |