Mattermost/Util/Logger.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod n/a totaltotal 92.3% 36 / 39 CC 2 SCAR 1.5
CC
2
Cov
93%
_build_logger
2.0
__ANON__
1.1
infof
1.1
CRAP 1.2
« Mattermost/V4/API/Object/Role/Timestamps.pm ↑ Summary Mattermost/V4/API.pm »
1 package WebService::Mattermost::Util::Logger;
2  
3 # ABSTRACT: Internal logger.
4  
5 14 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use Mojo::Util 'monkey_patch';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use Mojo::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 ▶use Types::Standard 'InstanceOf';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ################################################################################
11  
12 14 has logger => (is => 'ro', isa => InstanceOf['Mojo::Log'], lazy => 1, builder => 1);
13  
14 14 has logger_store => (is => 'rw', isa => InstanceOf['Mojo::Log']);
15  
16 ################################################################################
17  
18 monkey_patch 'Mojo::Log',
19 1 ▶ debugf => sub { shift->debug(sprintf shift, @_) },
Subroutine debugf: called CC=1 SCAR=0.0
20 0 ▶ infof => sub { shift->info(sprintf shift, @_) },
Subroutine __ANON__: not called CC=1 SCAR=1.2
Subroutine infof: called CC=1 SCAR=1.2
21 1 ▶ fatalf => sub { shift->fatal(sprintf shift, @_) },
Subroutine fatalf: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
22 1 ▶ warnf => sub { shift->warn(sprintf shift, @_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
23  
24 ################################################################################
25  
26 sub _build_logger {
27 9 ▶ my $self = shift;
Subroutine _build_logger: called CC=2 SCAR=7.0
28  
29 9 ▶ unless ($self->logger_store) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->logger_store) 9 0 9
30 9 $self->logger_store(Mojo::Log->new());
31 }
32  
33 9 return $self->logger_store;
34 }
35  
36 ################################################################################
37  
38 14 1;
39  
40 __END__
41  
42 =pod
43  
44 =encoding UTF-8
45  
46 =head1 NAME
47  
48 WebService::Mattermost::Util::Logger - Internal logger.
49  
50 =head1 VERSION
51  
52 version 0.28
53  
54 =head1 DESCRIPTION
55  
56 Patched instance of C<Mojo::Log> with some wrapping methods.
57  
58 =head2 ATTRIBUTES
59  
60 =over 4
61  
62 =item C<logger>
63  
64 A C<Mojo::Log> object with additional methods:
65  
66 =over 8
67  
68 =item C<debugf()>
69  
70 $self->logger->debugf('sprintf for %s', 'debug'); # sprintf for debug
71  
72 =item C<infof()>
73  
74 $self->logger->infof('sprintf for %s', 'info'); # sprintf for info
75  
76 =item C<fatalf()>
77  
78 $self->logger->fatalf('sprintf for %s', 'fatal'); # sprintf for fatal
79  
80 =item C<warnf()>
81  
82 $self->logger->warnf('sprintf for %s', 'warn'); # sprintf for warn
83  
84 =back
85  
86 =back
87  
88 =head1 AUTHOR
89  
90 Mike Jones <mike@netsplit.org.uk>
91  
92 =head1 COPYRIGHT AND LICENSE
93  
94 This software is Copyright (c) 2020 by Mike Jones.
95  
96 This is free software, licensed under:
97  
98 The MIT (X11) License
99  
100 =cut
« Mattermost/V4/API/Object/Role/Timestamps.pm ↑ Summary Mattermost/V4/API.pm »