line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XT::Files::Role::Logger; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
35
|
|
15660
|
use 5.006; |
|
35
|
|
|
|
|
127
|
|
4
|
35
|
|
|
35
|
|
200
|
use strict; |
|
35
|
|
|
|
|
337
|
|
|
35
|
|
|
|
|
868
|
|
5
|
35
|
|
|
35
|
|
189
|
use warnings; |
|
35
|
|
|
|
|
78
|
|
|
35
|
|
|
|
|
1589
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
8
|
|
|
|
|
|
|
|
9
|
35
|
|
|
35
|
|
213
|
use Role::Tiny; |
|
35
|
|
|
|
|
61
|
|
|
35
|
|
|
|
|
243
|
|
10
|
|
|
|
|
|
|
|
11
|
35
|
|
|
35
|
|
5481
|
use Carp (); |
|
35
|
|
|
|
|
68
|
|
|
35
|
|
|
|
|
689
|
|
12
|
35
|
|
|
35
|
|
184
|
use Scalar::Util (); |
|
35
|
|
|
|
|
65
|
|
|
35
|
|
|
|
|
612
|
|
13
|
35
|
|
|
35
|
|
218
|
use Test::Builder (); |
|
35
|
|
|
|
|
82
|
|
|
35
|
|
|
|
|
9545
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub log { ## no critic (Subroutines::ProhibitBuiltinHomonyms) |
16
|
30
|
|
|
30
|
1
|
5728
|
my ( $self, $msg ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
30
|
|
|
|
|
92
|
my $msg_with_prefix = $self->_msg_with_prefix($msg); |
19
|
30
|
|
|
|
|
129
|
Test::Builder->new->note($msg_with_prefix); |
20
|
|
|
|
|
|
|
|
21
|
30
|
|
|
|
|
9122
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub log_debug { |
25
|
12
|
|
|
12
|
1
|
5657
|
my ( $self, $msg ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
12
|
100
|
|
|
|
59
|
return if !$ENV{XT_FILES_DEBUG}; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
8
|
$self->log($msg); |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
11
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub log_fatal { |
35
|
26
|
|
|
26
|
1
|
3283
|
my ( $self, $msg ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
26
|
|
|
|
|
137
|
$self->log($msg); |
38
|
|
|
|
|
|
|
|
39
|
26
|
|
|
|
|
79
|
my $msg_with_prefix = $self->_msg_with_prefix($msg); |
40
|
|
|
|
|
|
|
|
41
|
26
|
|
|
|
|
79
|
my $package = __PACKAGE__; |
42
|
26
|
|
|
|
|
95
|
local $Carp::CarpInternal{$package} = 1; ## no critic (Variables::ProhibitPackageVars) |
43
|
26
|
|
|
|
|
2904
|
Carp::confess($msg_with_prefix); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub log_prefix { |
47
|
39
|
|
|
39
|
1
|
64
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
39
|
|
|
|
|
177
|
return Scalar::Util::blessed($self); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _msg_with_prefix { |
53
|
56
|
|
|
56
|
|
122
|
my ( $self, $msg ) = @_; |
54
|
|
|
|
|
|
|
|
55
|
56
|
|
|
|
|
160
|
my $msg_with_prefix = '[' . $self->log_prefix . '] ' . $msg; |
56
|
56
|
|
|
|
|
263
|
return $msg_with_prefix; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |