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
|
|
30
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1313
|
|
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
|
11
|
|
|
11
|
1
|
30
|
sub postfix { $_[0]->{'postfix'} } |
35
|
0
|
|
|
0
|
1
|
0
|
sub name { $_[0]->{'name'} } |
36
|
18
|
|
|
18
|
1
|
36
|
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
|
12
|
|
|
12
|
|
19
|
my $self = shift; |
51
|
12
|
|
|
|
|
27
|
my ($name, $postfix, $separator) = @_; |
52
|
12
|
100
|
|
|
|
79
|
$separator = " " unless defined $separator; |
53
|
12
|
|
|
|
|
38
|
$self->{name} = $name; |
54
|
12
|
|
|
|
|
72
|
$self->{postfix} = $postfix; |
55
|
12
|
|
|
|
|
19
|
$self->{separator} = $separator; |
56
|
12
|
|
|
|
|
29
|
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
|
18
|
|
|
18
|
1
|
26
|
my $self = shift; |
77
|
18
|
|
|
|
|
37
|
my ($str) = @_; # A Log::Agent::Message object |
78
|
|
|
|
|
|
|
|
79
|
18
|
|
|
|
|
48
|
my $string = $self->string; |
80
|
18
|
|
|
|
|
54
|
my $separator = $self->separator; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
# Merge into the Log::Agent::Message object string. |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
|
86
|
18
|
100
|
|
|
|
48
|
if ($self->postfix) { |
87
|
5
|
|
|
|
|
23
|
$str->append($separator . $string); |
88
|
|
|
|
|
|
|
} else { |
89
|
13
|
|
|
|
|
51
|
$str->prepend($string . $separator); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
18
|
|
|
|
|
43
|
return; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; # for "require" |
96
|
|
|
|
|
|
|
__END__ |