line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Dispatch::Base; |
2
|
|
|
|
|
|
|
|
3
|
29
|
|
|
29
|
|
259
|
use strict; |
|
29
|
|
|
|
|
61
|
|
|
29
|
|
|
|
|
917
|
|
4
|
29
|
|
|
29
|
|
152
|
use warnings; |
|
29
|
|
|
|
|
58
|
|
|
29
|
|
|
|
|
712
|
|
5
|
|
|
|
|
|
|
|
6
|
29
|
|
|
29
|
|
147
|
use Carp (); |
|
29
|
|
|
|
|
59
|
|
|
29
|
|
|
|
|
619
|
|
7
|
|
|
|
|
|
|
use Log::Dispatch::Vars |
8
|
29
|
|
|
29
|
|
148
|
qw( %CanonicalLevelNames %LevelNamesToNumbers @OrderedLevels ); |
|
29
|
|
|
|
|
58
|
|
|
29
|
|
|
|
|
3813
|
|
9
|
29
|
|
|
29
|
|
226
|
use Scalar::Util qw( refaddr ); |
|
29
|
|
|
|
|
69
|
|
|
29
|
|
|
|
|
14315
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '2.70'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
14
|
|
|
|
|
|
|
sub _level_as_number { |
15
|
187
|
|
|
187
|
|
334
|
my $self = shift; |
16
|
187
|
|
|
|
|
286
|
my $level = shift; |
17
|
|
|
|
|
|
|
|
18
|
187
|
|
|
|
|
651
|
my $level_name = $self->level_is_valid($level); |
19
|
186
|
100
|
|
|
|
457
|
return unless $level_name; |
20
|
|
|
|
|
|
|
|
21
|
185
|
|
|
|
|
607
|
return $LevelNamesToNumbers{$level_name}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
## use critic |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub level_is_valid { |
26
|
202
|
|
|
202
|
0
|
9399
|
shift; |
27
|
202
|
|
|
|
|
307
|
my $level = shift; |
28
|
|
|
|
|
|
|
|
29
|
202
|
100
|
|
|
|
471
|
if ( !defined $level ) { |
30
|
1
|
|
|
|
|
232
|
Carp::croak('Logging level was not provided'); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
201
|
100
|
66
|
|
|
945
|
if ( $level =~ /\A[0-9]+\z/ && $level <= $#OrderedLevels ) { |
34
|
15
|
|
|
|
|
45
|
return $OrderedLevels[$level]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
186
|
|
|
|
|
795
|
return $CanonicalLevelNames{$level}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
41
|
|
|
|
|
|
|
sub _apply_callbacks { |
42
|
86
|
|
|
86
|
|
170
|
my $self = shift; |
43
|
86
|
|
|
|
|
422
|
my %p = @_; |
44
|
|
|
|
|
|
|
|
45
|
86
|
|
|
|
|
227
|
my $msg = delete $p{message}; |
46
|
86
|
|
|
|
|
163
|
for my $cb ( @{ $self->{callbacks} } ) { |
|
86
|
|
|
|
|
469
|
|
47
|
89
|
|
|
|
|
319
|
$msg = $cb->( message => $msg, %p ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
86
|
|
|
|
|
490
|
return $msg; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub add_callback { |
54
|
5
|
|
|
5
|
0
|
3422
|
my $self = shift; |
55
|
5
|
|
|
|
|
12
|
my $value = shift; |
56
|
|
|
|
|
|
|
|
57
|
5
|
50
|
|
|
|
20
|
Carp::carp("given value $value is not a valid callback") |
58
|
|
|
|
|
|
|
unless ref $value eq 'CODE'; |
59
|
|
|
|
|
|
|
|
60
|
5
|
|
100
|
|
|
22
|
$self->{callbacks} ||= []; |
61
|
5
|
|
|
|
|
10
|
push @{ $self->{callbacks} }, $value; |
|
5
|
|
|
|
|
13
|
|
62
|
|
|
|
|
|
|
|
63
|
5
|
|
|
|
|
12
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub remove_callback { |
67
|
2
|
|
|
2
|
0
|
1310
|
my $self = shift; |
68
|
2
|
|
|
|
|
4
|
my $cb = shift; |
69
|
|
|
|
|
|
|
|
70
|
2
|
50
|
|
|
|
9
|
Carp::carp("given value $cb is not a valid callback") |
71
|
|
|
|
|
|
|
unless ref $cb eq 'CODE'; |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
8
|
my $cb_id = refaddr $cb; |
74
|
|
|
|
|
|
|
$self->{callbacks} |
75
|
2
|
|
|
|
|
3
|
= [ grep { refaddr $_ ne $cb_id } @{ $self->{callbacks} } ]; |
|
3
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
7
|
|
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
6
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# ABSTRACT: Code shared by dispatch and output objects. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=encoding UTF-8 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Log::Dispatch::Base - Code shared by dispatch and output objects. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 VERSION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
version 2.70 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SYNOPSIS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
use Log::Dispatch::Base; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
... |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
@ISA = qw(Log::Dispatch::Base); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 DESCRIPTION |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Unless you are me, you probably don't need to know what this class |
109
|
|
|
|
|
|
|
does. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=for Pod::Coverage .* |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SUPPORT |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Log-Dispatch/issues>. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SOURCE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The source code repository for Log-Dispatch can be found at L<https://github.com/houseabsolute/Log-Dispatch>. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Dave Rolsky. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This is free software, licensed under: |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The full text of the license can be found in the |
136
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |