| 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'
MC/DC100%1/1
$conf->{'level'} || 'debug'
$conf->{'level'}
Truth table100%2/2
A
A= $conf->{'level'}
| |||||||||||||
| 9 | 3 | ▶ | die "$level: unsupported log-level" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 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__ | ||||||||||||