line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::LogFilter; |
2
|
2
|
|
|
2
|
|
1571
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
78
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
76
|
|
4
|
2
|
|
|
2
|
|
954
|
use parent qw(Plack::Middleware); |
|
2
|
|
|
|
|
383
|
|
|
2
|
|
|
|
|
16
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
17805
|
use Plack::Util::Accessor qw(filter); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub call { |
11
|
1
|
|
|
1
|
1
|
251760
|
my ($self, $env) = @_; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
7
|
$env->{'psgi.errors'} = |
14
|
|
|
|
|
|
|
Plack::Middleware::LogFilter::_wrap->new( |
15
|
|
|
|
|
|
|
$env, |
16
|
|
|
|
|
|
|
$self->filter, |
17
|
|
|
|
|
|
|
); |
18
|
1
|
|
|
|
|
21
|
my $res = $self->app->($env); |
19
|
1
|
|
|
|
|
21
|
return $res; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Plack::Middleware::LogFilter::_wrap; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
1
|
|
|
1
|
|
95
|
my ($class, $env, $filter) = @_; |
27
|
|
|
|
|
|
|
return bless { |
28
|
|
|
|
|
|
|
env => $env, |
29
|
|
|
|
|
|
|
'_psgi.errors' => $env->{'psgi.errors'}, |
30
|
0
|
|
|
0
|
|
0
|
filter => $filter || sub { return 1; }, |
31
|
1
|
|
50
|
|
|
12
|
}, $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub print { |
35
|
2
|
|
|
2
|
|
32
|
my ($self, $output) = @_; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
7
|
my $filter = $self->{filter}; |
38
|
2
|
100
|
66
|
|
|
20
|
if (!$filter || (ref $filter eq 'CODE' && $filter->($self->{env}, $output))) { |
|
|
|
33
|
|
|
|
|
39
|
1
|
|
|
|
|
20
|
return $self->{'_psgi.errors'}->print($output); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |