line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Stderr; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19592
|
use 5.008000; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
60
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use Carp ; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
116
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use base 'Exporter' ; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
533
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @LOG_CONSTANTS = qw{ |
14
|
|
|
|
|
|
|
LOG_NONE LOG_EMERG LOG_ALERT |
15
|
|
|
|
|
|
|
LOG_CRIT LOG_ERR LOG_WARNING |
16
|
|
|
|
|
|
|
LOG_NOTICE LOG_INFO LOG_DEBUG |
17
|
|
|
|
|
|
|
} ; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my @LOG_ALIASES = qw{ |
20
|
|
|
|
|
|
|
LOG_ERROR LOG_WARN |
21
|
|
|
|
|
|
|
} ; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @FUNCTIONS = qw{ logger } ; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my @TAGS = qw{all constants aliases} ; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my @SYMBOLS = ( @LOG_CONSTANTS, @LOG_ALIASES, @FUNCTIONS ) ; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @EXPORT_OK = ( @SYMBOLS, @TAGS ) ; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
32
|
|
|
|
|
|
|
all => \@SYMBOLS, |
33
|
|
|
|
|
|
|
constants => \@LOG_CONSTANTS, |
34
|
|
|
|
|
|
|
aliases => \@LOG_ALIASES, |
35
|
|
|
|
|
|
|
) ; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
0
|
sub LOG_NONE { return 0 } ; |
38
|
0
|
|
|
0
|
1
|
0
|
sub LOG_EMERG { return 1 } ; |
39
|
0
|
|
|
0
|
1
|
0
|
sub LOG_ALERT { return 2 } ; |
40
|
0
|
|
|
0
|
1
|
0
|
sub LOG_CRIT { return 3 } ; |
41
|
0
|
|
|
0
|
1
|
0
|
sub LOG_ERR { return 4 } ; |
42
|
0
|
|
|
0
|
1
|
0
|
sub LOG_WARNING { return 5 } ; |
43
|
1
|
|
|
1
|
1
|
2
|
sub LOG_NOTICE { return 6 } ; |
44
|
0
|
|
|
0
|
1
|
|
sub LOG_INFO { return 7 } ; |
45
|
0
|
|
|
0
|
1
|
|
sub LOG_DEBUG { return 8 } ; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Aliases |
48
|
|
|
|
|
|
|
*LOG_ERROR = \&LOG_ERR ; |
49
|
|
|
|
|
|
|
*LOG_WARN = \&LOG_WARNING ; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Default DEBUGLEVEL = LOG_NOTICE |
52
|
|
|
|
|
|
|
our $DEBUGLEVEL = LOG_NOTICE ; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub logger { |
56
|
0
|
|
|
0
|
0
|
|
my ($level,$message) = @_ ; |
57
|
0
|
|
|
|
|
|
my $caller = (caller(1))[3] ; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
$caller = "-e" if not $caller ; |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
return if $level > $DEBUGLEVEL ; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
$message .= qq{\n} if not $message =~ m{\n$} ; |
64
|
0
|
|
|
|
|
|
my $now = scalar localtime ; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $log ; |
67
|
0
|
|
|
|
|
|
$log = qq{[$now] } ; |
68
|
0
|
0
|
|
|
|
|
$log .= qq{[$caller] } if $DEBUGLEVEL >= LOG_DEBUG ; |
69
|
0
|
|
|
|
|
|
$log .= $message ; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
print STDERR $log ; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |