line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###########################################################################
|
2
|
|
|
|
|
|
|
#
|
3
|
|
|
|
|
|
|
# Tag.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
|
4
|
|
|
4
|
|
27
|
use strict;
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1267
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
########################################################################
|
17
|
|
|
|
|
|
|
package Log::Agent::Tag;
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#
|
20
|
|
|
|
|
|
|
# ->make
|
21
|
|
|
|
|
|
|
#
|
22
|
|
|
|
|
|
|
# Creation routine.
|
23
|
|
|
|
|
|
|
#
|
24
|
|
|
|
|
|
|
sub make {
|
25
|
0
|
|
|
0
|
0
|
0
|
my $self = bless {}, shift;
|
26
|
0
|
|
|
|
|
0
|
require Carp;
|
27
|
0
|
|
|
|
|
0
|
Carp::confess("deferred");
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#
|
31
|
|
|
|
|
|
|
# Attribute access
|
32
|
|
|
|
|
|
|
#
|
33
|
|
|
|
|
|
|
|
34
|
10
|
|
|
10
|
1
|
25
|
sub postfix { $_[0]->{'postfix'} }
|
35
|
0
|
|
|
0
|
1
|
0
|
sub name { $_[0]->{'name'} }
|
36
|
17
|
|
|
17
|
1
|
32
|
sub separator { $_[0]->{'separator'} }
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#
|
39
|
|
|
|
|
|
|
# ->_init
|
40
|
|
|
|
|
|
|
#
|
41
|
|
|
|
|
|
|
# Initialization routine for common attributes:
|
42
|
|
|
|
|
|
|
#
|
43
|
|
|
|
|
|
|
# postfix if true, appends tag to message, otherwise prepends
|
44
|
|
|
|
|
|
|
# name the tag name
|
45
|
|
|
|
|
|
|
# separator the string to use before or after tag (defaults to " ")
|
46
|
|
|
|
|
|
|
#
|
47
|
|
|
|
|
|
|
# Called by each creation routine in heirs.
|
48
|
|
|
|
|
|
|
#
|
49
|
|
|
|
|
|
|
sub _init {
|
50
|
11
|
|
|
11
|
|
19
|
my $self = shift;
|
51
|
11
|
|
|
|
|
24
|
my ($name, $postfix, $separator) = @_;
|
52
|
11
|
100
|
|
|
|
42
|
$separator = " " unless defined $separator;
|
53
|
11
|
|
|
|
|
35
|
$self->{name} = $name;
|
54
|
11
|
|
|
|
|
38
|
$self->{postfix} = $postfix;
|
55
|
11
|
|
|
|
|
31
|
$self->{separator} = $separator;
|
56
|
11
|
|
|
|
|
27
|
return;
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#
|
60
|
|
|
|
|
|
|
# ->string -- deferred
|
61
|
|
|
|
|
|
|
#
|
62
|
|
|
|
|
|
|
# Build tag string.
|
63
|
|
|
|
|
|
|
# Must be implemented by heirs.
|
64
|
|
|
|
|
|
|
#
|
65
|
|
|
|
|
|
|
sub string {
|
66
|
0
|
|
|
0
|
1
|
0
|
require Carp;
|
67
|
0
|
|
|
|
|
0
|
Carp::confess("deferred");
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#
|
71
|
|
|
|
|
|
|
# ->insert -- frozen
|
72
|
|
|
|
|
|
|
#
|
73
|
|
|
|
|
|
|
# Merge string into the log message, according to our configuration.
|
74
|
|
|
|
|
|
|
#
|
75
|
|
|
|
|
|
|
sub insert {
|
76
|
17
|
|
|
17
|
1
|
26
|
my $self = shift;
|
77
|
17
|
|
|
|
|
42
|
my ($str) = @_; # A Log::Agent::Message object
|
78
|
|
|
|
|
|
|
|
79
|
17
|
|
|
|
|
49
|
my $string = $self->string;
|
80
|
17
|
|
|
|
|
54
|
my $separator = $self->separator;
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#
|
83
|
|
|
|
|
|
|
# Merge into the Log::Agent::Message object string.
|
84
|
|
|
|
|
|
|
#
|
85
|
|
|
|
|
|
|
|
86
|
17
|
100
|
|
|
|
46
|
if ($self->postfix) {
|
87
|
5
|
|
|
|
|
36
|
$str->append($separator . $string);
|
88
|
|
|
|
|
|
|
} else {
|
89
|
12
|
|
|
|
|
52
|
$str->prepend($string . $separator);
|
90
|
|
|
|
|
|
|
}
|
91
|
|
|
|
|
|
|
|
92
|
17
|
|
|
|
|
59
|
return;
|
93
|
|
|
|
|
|
|
}
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; # for "require"
|
96
|
|
|
|
|
|
|
__END__
|