line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
########################################################################### |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Tag_List.pm |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copyright (C) 1999 Raphael Manfredi. |
6
|
|
|
|
|
|
|
# Copyright (C) 2002-2017 Mark Rogaski, mrogaski@cpan.org; |
7
|
|
|
|
|
|
|
# all rights reserved. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# See the README file included with the |
10
|
|
|
|
|
|
|
# distribution for license information. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
########################################################################## |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
99
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
######################################################################## |
17
|
|
|
|
|
|
|
package Log::Agent::Tag_List; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require Tie::Array; # contains Tie::StdArray |
20
|
2
|
|
|
2
|
|
11
|
use vars qw(@ISA); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
624
|
|
21
|
|
|
|
|
|
|
@ISA = qw(Tie::StdArray); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
# A list of all log message tags recorded, with dedicated methods to |
25
|
|
|
|
|
|
|
# manipulate them. |
26
|
|
|
|
|
|
|
# |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# ->make |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# Creation routine. |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
sub make { |
34
|
2
|
|
|
2
|
0
|
6
|
my $self = bless [], shift; |
35
|
2
|
|
|
|
|
5
|
my (@tags) = @_; |
36
|
2
|
|
|
|
|
12
|
@$self = @tags; |
37
|
2
|
|
|
|
|
42
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
# _typecheck |
42
|
|
|
|
|
|
|
# |
43
|
|
|
|
|
|
|
# Make sure only objects of the proper type are given in the list. |
44
|
|
|
|
|
|
|
# Croaks when type checking detects an error. |
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
sub _typecheck { |
47
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
48
|
2
|
|
|
|
|
6
|
my ($type, $list) = @_; |
49
|
2
|
|
33
|
|
|
6
|
my @bad = grep { !ref $_ || !$_->isa($type) } @$list; |
|
2
|
|
|
|
|
36
|
|
50
|
2
|
50
|
|
|
|
8
|
return unless @bad; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
my $first = $bad[0]; |
53
|
0
|
|
|
|
|
0
|
require Carp; |
54
|
0
|
|
|
|
|
0
|
Carp::croak(sprintf |
55
|
|
|
|
|
|
|
"Expected list of $type, got %d bad (first one is $first)", |
56
|
|
|
|
|
|
|
scalar(@bad)); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# |
60
|
|
|
|
|
|
|
# ->append |
61
|
|
|
|
|
|
|
# |
62
|
|
|
|
|
|
|
# Append list of Log::Agent::Tag objects to current list. |
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
sub append { |
65
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
66
|
1
|
|
|
|
|
4
|
my (@tags) = @_; |
67
|
1
|
|
|
|
|
5
|
$self->_typecheck("Log::Agent::Tag", \@tags); |
68
|
1
|
|
|
|
|
4
|
push @$self, @tags; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
# ->prepend |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# Prepend list of Log::Agent::Tag objects to current list. |
75
|
|
|
|
|
|
|
# |
76
|
|
|
|
|
|
|
sub prepend { |
77
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
78
|
1
|
|
|
|
|
3
|
my (@tags) = @_; |
79
|
1
|
|
|
|
|
6
|
$self->_typecheck("Log::Agent::Tag", \@tags); |
80
|
1
|
|
|
|
|
4
|
unshift @$self, @tags; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; # for require |
84
|
|
|
|
|
|
|
__END__ |