line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
########################################################################### |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Priority.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
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
######################################################################## |
17
|
|
|
|
|
|
|
package Log::Agent::Tag::Priority; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require Log::Agent::Tag::String; |
20
|
1
|
|
|
1
|
|
20
|
use vars qw(@ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
93
|
|
21
|
|
|
|
|
|
|
@ISA = qw(Log::Agent::Tag::String); |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
29
|
use Log::Agent::Priorities qw(level_from_prio prio_from_level); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
357
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# ->make |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
# Creation routine. |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# Calling arguments: a hash table list. |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
# The keyed argument list may contain: |
33
|
|
|
|
|
|
|
# -POSTFIX whether to postfix log message or prefix it. |
34
|
|
|
|
|
|
|
# -SEPARATOR separator string to use between tag and message |
35
|
|
|
|
|
|
|
# -DISPLAY a string like '[$priority:$level])' |
36
|
|
|
|
|
|
|
# -PRIORITY the log priority string, e.g. "warning". |
37
|
|
|
|
|
|
|
# -LEVEL the log level value, e.g. 4. |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
# Attributes: |
40
|
|
|
|
|
|
|
# none, besides the inherited ones |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
sub make { |
43
|
5
|
|
|
5
|
0
|
11
|
my $type = shift; |
44
|
5
|
|
|
|
|
21
|
my (%args) = @_; |
45
|
5
|
|
|
|
|
9
|
my $separator = " "; |
46
|
5
|
|
|
|
|
6
|
my $postfix = 0; |
47
|
5
|
|
|
|
|
10
|
my ($display, $priority, $level); |
48
|
|
|
|
|
|
|
|
49
|
5
|
|
|
|
|
16
|
my %set = ( |
50
|
|
|
|
|
|
|
-display => \$display, |
51
|
|
|
|
|
|
|
-postfix => \$postfix, |
52
|
|
|
|
|
|
|
-separator => \$separator, |
53
|
|
|
|
|
|
|
-priority => \$priority, |
54
|
|
|
|
|
|
|
-level => \$level, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
5
|
|
|
|
|
19
|
while (my ($arg, $val) = each %args) { |
58
|
20
|
|
|
|
|
33
|
my $vset = $set{lc($arg)}; |
59
|
20
|
100
|
|
|
|
49
|
next unless ref $vset; |
60
|
15
|
|
|
|
|
43
|
$$vset = $val; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
# Normalize $priority to the full name (e.g. "err" -> "error") |
65
|
|
|
|
|
|
|
# |
66
|
|
|
|
|
|
|
|
67
|
5
|
|
|
|
|
139
|
$priority = prio_from_level level_from_prio $priority; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# |
70
|
|
|
|
|
|
|
# Format according to -display specs. |
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
# Since priority and level are fixed for this object, the resulting |
73
|
|
|
|
|
|
|
# string need only be computed once, i.e. now. |
74
|
|
|
|
|
|
|
# |
75
|
|
|
|
|
|
|
# The following variables are recognized: |
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
# $priority priority name (e.g. "warning") |
78
|
|
|
|
|
|
|
# $level logging level |
79
|
|
|
|
|
|
|
# |
80
|
|
|
|
|
|
|
# We recognize both $level and ${level}. |
81
|
|
|
|
|
|
|
# |
82
|
|
|
|
|
|
|
|
83
|
5
|
|
|
|
|
21
|
$display =~ s/\$priority\b/$priority/g; |
84
|
5
|
|
|
|
|
10
|
$display =~ s/\$\{priority}/$priority/g; |
85
|
5
|
|
|
|
|
13
|
$display =~ s/\$level\b/$level/g; |
86
|
5
|
|
|
|
|
11
|
$display =~ s/\$\{level}/$level/g; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
# Now create the constant tag string. |
90
|
|
|
|
|
|
|
# |
91
|
|
|
|
|
|
|
|
92
|
5
|
|
|
|
|
24
|
my $self = Log::Agent::Tag::String->make( |
93
|
|
|
|
|
|
|
-name => "priority", |
94
|
|
|
|
|
|
|
-value => $display, |
95
|
|
|
|
|
|
|
-postfix => $postfix, |
96
|
|
|
|
|
|
|
-separator => $separator, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
5
|
|
|
|
|
109
|
return bless $self, $type; # re-blessed in our package |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; # for "require" |
103
|
|
|
|
|
|
|
__END__ |