line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::Log::Contextual; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19940
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
18
|
use 5.008_001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
66
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
797
|
use parent qw(Plack::Middleware); |
|
1
|
|
|
|
|
281
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
use Plack::Util::Accessor qw(level logger); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Log::Contextual qw(with_logger); |
11
|
|
|
|
|
|
|
use Plack::Middleware::Log::Contextual::Logger; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub call { |
14
|
|
|
|
|
|
|
my($self, $env) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $logger = $self->logger; |
17
|
|
|
|
|
|
|
unless ($logger) { |
18
|
|
|
|
|
|
|
if ($env->{'psgix.logger'}) { |
19
|
|
|
|
|
|
|
$logger = Plack::Middleware::Log::Contextual::Logger->new($env->{'psgix.logger'}, $self->level); |
20
|
|
|
|
|
|
|
} else { |
21
|
|
|
|
|
|
|
$env->{'psgi.errors'}->print(__PACKAGE__ . ": logger or psgix.logger is not available.\n"); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $res; |
26
|
|
|
|
|
|
|
with_logger $logger, sub { $res = $self->app->($env) }; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
if (ref $res eq 'CODE') { |
29
|
|
|
|
|
|
|
return sub { |
30
|
|
|
|
|
|
|
my $r = shift; |
31
|
|
|
|
|
|
|
with_logger $logger, sub { $res->($r) }; |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return $res; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
require Plack::Middleware::Log::Contextual; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |