line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::LogDispatchouli; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
69281
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
28
|
use 5.008_005; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
6
|
use parent qw(Plack::Middleware); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
15929
|
use Plack::Util::Accessor qw(logger); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
32
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
9
|
1
|
|
|
1
|
|
4
|
use Scalar::Util qw(blessed); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
922
|
use Log::Dispatchouli; |
|
1
|
|
|
|
|
39699
|
|
|
1
|
|
|
|
|
263
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub prepare_app { |
16
|
2
|
|
|
2
|
1
|
29652
|
my $self = shift; |
17
|
2
|
50
|
|
|
|
13
|
unless ($self->logger) { |
18
|
0
|
|
|
|
|
0
|
Carp::croak "logger is not defined"; |
19
|
|
|
|
|
|
|
} |
20
|
2
|
100
|
|
|
|
23
|
$self->logger( Log::Dispatchouli->new($self->logger) ) |
21
|
|
|
|
|
|
|
if ref $self->logger eq 'HASH'; |
22
|
2
|
50
|
33
|
|
|
324
|
Carp::croak "logger is not a Log::Dispatchouli object or constructor parameter hash" |
23
|
|
|
|
|
|
|
unless blessed($self->logger) and $self->logger->isa("Log::Dispatchouli"); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub call { |
27
|
2
|
|
|
2
|
1
|
26436
|
my($self, $env) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$env->{'psgix.logger'} = sub { |
30
|
8
|
|
|
8
|
|
1528
|
my $args = shift; |
31
|
8
|
|
|
|
|
19
|
my $msg = delete $args->{message}; |
32
|
|
|
|
|
|
|
|
33
|
8
|
100
|
|
|
|
27
|
($args->{fatal}, $args->{level}) = (1, 'error') |
34
|
|
|
|
|
|
|
if $args->{level} eq 'fatal'; |
35
|
|
|
|
|
|
|
|
36
|
8
|
100
|
100
|
|
|
36
|
if ( ref $msg && ref $msg ne 'CODE' ) { |
37
|
2
|
|
|
|
|
53
|
$msg .= q{}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
8
|
|
|
|
|
34
|
$self->logger->log($args, $msg); |
41
|
2
|
|
|
|
|
15
|
}; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
17
|
$self->app->($env); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |