line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::ChromeLogger; |
2
|
2
|
|
|
2
|
|
37436
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
82
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
1836
|
use Web::ChromeLogger; |
|
2
|
|
|
|
|
21673
|
|
|
2
|
|
|
|
|
68
|
|
5
|
2
|
|
|
2
|
|
3771
|
use parent 'Plack::Middleware'; |
|
2
|
|
|
|
|
335
|
|
|
2
|
|
|
|
|
15
|
|
6
|
2
|
|
|
2
|
|
36803
|
use Plack::Util; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
7
|
2
|
|
|
|
|
13
|
use Plack::Util::Accessor qw/ |
8
|
|
|
|
|
|
|
json_encoder |
9
|
|
|
|
|
|
|
enable_in_production |
10
|
|
|
|
|
|
|
disabled |
11
|
2
|
|
|
2
|
|
11
|
/; |
|
2
|
|
|
|
|
3
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub prepare_app { |
16
|
1
|
|
|
1
|
1
|
90
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
1
|
0
|
33
|
|
|
7
|
if ( $ENV{PLACK_ENV} && $ENV{PLACK_ENV} eq 'production' |
|
|
|
33
|
|
|
|
|
19
|
|
|
|
|
|
|
&& !$self->enable_in_production ) { |
20
|
0
|
|
|
|
|
0
|
$self->disabled(1); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub call { |
25
|
1
|
|
|
1
|
1
|
20074
|
my ($self, $env) = @_; |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
7
|
unless ( $self->disabled ) { |
28
|
1
|
|
|
|
|
123
|
$env->{'psgix.chrome_logger'} = Web::ChromeLogger->new( |
29
|
|
|
|
|
|
|
json_encoder => $self->json_encoder, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
58
|
my $res = $self->app->($env); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->response_cb($res, sub { |
36
|
1
|
50
|
|
1
|
|
24
|
return if $self->disabled; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
13
|
my $h = Plack::Util::headers($_[0]->[1]); |
39
|
1
|
|
|
|
|
48
|
$h->set('X-ChromeLogger-Data' => $env->{'psgix.chrome_logger'}->finalize); |
40
|
1
|
|
|
|
|
48
|
}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |