line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::StaticLog; |
2
|
3
|
|
|
3
|
|
2210
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
26
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub register { |
7
|
3
|
|
|
3
|
1
|
136
|
my ($self, $app, $conf) = @_; |
8
|
3
|
|
100
|
|
|
24
|
my $level = $conf->{level} || 'debug'; |
9
|
3
|
50
|
|
|
|
21
|
die "$level: unsupported log-level" |
10
|
|
|
|
|
|
|
unless $level =~ /^(debug|info|warn|error|fatal)$/; |
11
|
|
|
|
|
|
|
$app->hook( |
12
|
|
|
|
|
|
|
after_static => sub { |
13
|
5
|
|
|
5
|
|
74261
|
my $c = shift; |
14
|
5
|
|
|
|
|
19
|
my $log = $c->app->log; |
15
|
5
|
100
|
|
|
|
53
|
return unless $log->is_level($level); |
16
|
2
|
|
|
|
|
38
|
my $path = $c->req->url->path; |
17
|
2
|
|
|
|
|
45
|
my $size = sprintf '%6s', $c->res->content->body_size; |
18
|
2
|
|
|
|
|
97
|
my $code = $c->res->code; |
19
|
2
|
|
|
|
|
44
|
$log->$level("Static $code $size $path"); |
20
|
3
|
|
|
|
|
39
|
}); |
21
|
3
|
|
|
|
|
76
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
__END__ |