| 1 | package Gears::Logger; | ||||||||||||||||||||
| 2 | 2 | $Gears::Logger::VERSION = '0.105'; | |||||||||||||||||||
| 3 | 2 | ▶ | use v5.40; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use Mooish::Base -standard; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | ▶ | use Time::Piece; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | # apache format | ||||||||||||||||||||
| 10 | 2 | has param 'date_format' => ( | |||||||||||||||||||
| 11 | isa => Str, | ||||||||||||||||||||
| 12 | default => '%a %b %d %T %Y' | ||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | # apache-like format | ||||||||||||||||||||
| 16 | 2 | has param 'log_format' => ( | |||||||||||||||||||
| 17 | isa => Maybe [Str], | ||||||||||||||||||||
| 18 | default => '[%s] [%s] %s' | ||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | # implements actual logging of a single message | ||||||||||||||||||||
| 22 | # must be reimplemented | ||||||||||||||||||||
| 23 | 0 | ▶ | sub _log_message ($self, $level, $message) | ||||||||||||||||||
|
Subroutine
_log_message: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 24 | { | ||||||||||||||||||||
| 25 | 0 | ...; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 4 | ▶ | sub message ($self, $level, @messages) | ||||||||||||||||||
|
Subroutine
message: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||
| 29 | { | ||||||||||||||||||||
| 30 | 4 | my $format = $self->log_format; | |||||||||||||||||||
| 31 | 4 | my $date; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 4 | for my $message (@messages) { | |||||||||||||||||||
| 34 | 5 | ▶ | $message = ref $message ? Dumper($message) : $message; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | 5 | chomp $message; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 5 | ▶ | if (defined $format) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | 5 | ▶ | $date //= localtime->strftime($self->date_format); | ||||||||||||||||||
|
Condition66%2/3
$date //= Gears::Logger::localtime()->strftime($self->date_format)
MC/DC0%0/2
$date //= Gears::Logger::localtime()->strftime($self->date_format)
$date
Gears::Logger::localtime()->strftime($self->date_format)
Truth table66%2/3
A //= B
A= $dateB= Gears::Logger::localtime()->strftime($self->date_format)
| |||||||||||||||||||||
| 39 | 5 | $message = sprintf $format, $date, uc $level, $message; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 5 | $self->_log_message($level, $message); | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 4 | return $self; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||