blib/lib/Mojolicious/Plugin/StaticLog.pm

filter: Statementstmt 100% 17 / 17 Branchbran 75.0% 3 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 96.4% 27 / 28 CC 4 SCAR 8.5
CC
4
Cov
96%
register
3.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.3
↑ Summary
1 package Mojolicious::Plugin::StaticLog;
2 3 ▶use Mojo::Base 'Mojolicious::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 3 our $VERSION = '0.07';
5  
6 3 ▶sub register {
Subroutine register: called CC=3 SCAR=11.0
Pod documented
7 3 my ($self, $app, $conf) = @_;
8 3 ▶ my $level = $conf->{level} || 'debug';
Condition100%2/2
$conf->{'level'} || 'debug'
l!l
12
MC/DC100%1/1
$conf->{'level'} || 'debug'
$conf->{'level'}
Truth table100%2/2
A
A= $conf->{'level'}
Aresult
11
00
9 3 ▶ die "$level: unsupported log-level"
Branch: 1 branch
BranchTrueFalseTotal
unless $level =~ /^(debug|info|warn|error|fatal)$/u 0 3 3
10 unless $level =~ /^(debug|info|warn|error|fatal)$/;
11 $app->hook(
12 5 ▶ after_static => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
13 5 my $c = shift;
14 5 my $log = $c->app->log;
15 5 ▶ return unless $log->is_level($level);
Branch: 1 branch
BranchTrueFalseTotal
unless $log->is_level($level) 3 2 5
16 2 my $path = $c->req->url->path;
17 2 my $size = sprintf '%6s', $c->res->content->body_size;
18 2 my $code = $c->res->code;
19 2 $log->$level("Static $code $size $path");
20 3 });
21 3 return;
22 }
23  
24 3 1;
25 __END__
↑ Summary