line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XT::Files::Role::Logger; |
2
|
|
|
|
|
|
|
|
3
|
37
|
|
|
37
|
|
17285
|
use 5.006; |
|
37
|
|
|
|
|
140
|
|
4
|
37
|
|
|
37
|
|
263
|
use strict; |
|
37
|
|
|
|
|
386
|
|
|
37
|
|
|
|
|
891
|
|
5
|
37
|
|
|
37
|
|
205
|
use warnings; |
|
37
|
|
|
|
|
106
|
|
|
37
|
|
|
|
|
1745
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
8
|
|
|
|
|
|
|
|
9
|
37
|
|
|
37
|
|
234
|
use Role::Tiny; |
|
37
|
|
|
|
|
98
|
|
|
37
|
|
|
|
|
267
|
|
10
|
|
|
|
|
|
|
|
11
|
37
|
|
|
37
|
|
6049
|
use Carp (); |
|
37
|
|
|
|
|
88
|
|
|
37
|
|
|
|
|
679
|
|
12
|
37
|
|
|
37
|
|
206
|
use Scalar::Util (); |
|
37
|
|
|
|
|
102
|
|
|
37
|
|
|
|
|
737
|
|
13
|
37
|
|
|
37
|
|
207
|
use Test::Builder (); |
|
37
|
|
|
|
|
72
|
|
|
37
|
|
|
|
|
10272
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub log { ## no critic (Subroutines::ProhibitBuiltinHomonyms) |
16
|
31
|
|
|
31
|
1
|
5740
|
my ( $self, $msg ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
31
|
|
|
|
|
122
|
my $msg_with_prefix = $self->_msg_with_prefix($msg); |
19
|
31
|
|
|
|
|
146
|
Test::Builder->new->note($msg_with_prefix); |
20
|
|
|
|
|
|
|
|
21
|
31
|
|
|
|
|
9749
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub log_debug { |
25
|
12
|
|
|
12
|
1
|
5577
|
my ( $self, $msg ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
12
|
100
|
|
|
|
75
|
return if !$ENV{XT_FILES_DEBUG}; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
8
|
$self->log($msg); |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
6
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub log_fatal { |
35
|
27
|
|
|
27
|
1
|
3267
|
my ( $self, $msg ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
27
|
|
|
|
|
150
|
$self->log($msg); |
38
|
|
|
|
|
|
|
|
39
|
27
|
|
|
|
|
88
|
my $msg_with_prefix = $self->_msg_with_prefix($msg); |
40
|
|
|
|
|
|
|
|
41
|
27
|
|
|
|
|
95
|
my $package = __PACKAGE__; |
42
|
27
|
|
|
|
|
104
|
local $Carp::CarpInternal{$package} = 1; ## no critic (Variables::ProhibitPackageVars) |
43
|
27
|
|
|
|
|
3015
|
Carp::confess($msg_with_prefix); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub log_prefix { |
47
|
41
|
|
|
41
|
1
|
85
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
41
|
|
|
|
|
207
|
return Scalar::Util::blessed($self); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _msg_with_prefix { |
53
|
58
|
|
|
58
|
|
130
|
my ( $self, $msg ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
58
|
|
|
|
|
166
|
my $msg_with_prefix = '[' . $self->log_prefix . '] ' . $msg; |
56
|
58
|
|
|
|
|
244
|
return $msg_with_prefix; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |