line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
531581
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
2
|
1
|
|
|
1
|
|
35
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
74
|
|
3
|
|
|
|
|
|
|
package Plack::Middleware::LogErrors; |
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
$Plack::Middleware::LogErrors::VERSION = '0.001'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
# git description: e135274 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
1
|
|
|
1
|
|
20
|
$Plack::Middleware::LogErrors::AUTHORITY = 'cpan:ETHER'; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
# ABSTRACT: Map psgi.errors to psgix.logger or other logger |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
55
|
use parent 'Plack::Middleware'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
21484
|
use Plack::Util::Accessor 'logger'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
17
|
1
|
|
|
1
|
|
40
|
use Scalar::Util 'reftype'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
341
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub prepare_app |
20
|
|
|
|
|
|
|
{ |
21
|
4
|
|
|
4
|
1
|
24729
|
my $self = shift; |
22
|
4
|
100
|
100
|
|
|
25
|
die "'logger' is not a coderef!" |
23
|
|
|
|
|
|
|
if $self->logger and not __isa_coderef($self->logger); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub call |
27
|
|
|
|
|
|
|
{ |
28
|
3
|
|
|
3
|
1
|
55860
|
my ($self, $env) = @_; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
100
|
|
|
19
|
my $logger = $self->logger || $env->{'psgix.logger'}; |
31
|
|
|
|
|
|
|
|
32
|
3
|
100
|
|
|
|
57
|
die 'no psgix.logger in $env; cannot map psgi.errors to it!' |
33
|
|
|
|
|
|
|
if not $logger; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# convert to something that matches the psgi.errors specs |
36
|
2
|
|
|
|
|
20
|
$env->{'psgi.errors'} = Plack::Middleware::LogErrors::LogHandle->new($logger); |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
15
|
return $self->app->($env); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub __isa_coderef |
42
|
|
|
|
|
|
|
{ |
43
|
2
|
100
|
50
|
2
|
|
171
|
ref $_[0] eq 'CODE' |
|
|
|
66
|
|
|
|
|
44
|
|
|
|
|
|
|
or (reftype($_[0]) || '') eq 'CODE' |
45
|
|
|
|
|
|
|
or overload::Method($_[0], '&{}') |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Plack::Middleware::LogErrors::LogHandle; |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
$Plack::Middleware::LogErrors::LogHandle::VERSION = '0.001'; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
# git description: e135274 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
BEGIN { |
55
|
1
|
|
|
1
|
|
111
|
$Plack::Middleware::LogErrors::LogHandle::AUTHORITY = 'cpan:ETHER'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
# ABSTRACT: convert psgix.logger-like logger into an IO::Handle-like object |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new |
60
|
|
|
|
|
|
|
{ |
61
|
2
|
|
|
2
|
|
4
|
my ($class, $logger) = @_; |
62
|
2
|
|
|
|
|
13
|
return bless { logger => $logger }, $class; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub print |
66
|
|
|
|
|
|
|
{ |
67
|
2
|
|
|
2
|
|
45
|
my ($self, $message) = @_; |
68
|
2
|
|
|
|
|
16
|
$self->{logger}->({ |
69
|
|
|
|
|
|
|
level => 'error', |
70
|
|
|
|
|
|
|
message => $message, |
71
|
|
|
|
|
|
|
}); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |