line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## |
2
|
|
|
|
|
|
|
## Schedule::Chronic::Logger |
3
|
|
|
|
|
|
|
## Author: Vipul Ved Prakash . |
4
|
|
|
|
|
|
|
## $Id: Logger.pm,v 1.2 2004/07/26 23:12:49 hackworth Exp $ |
5
|
|
|
|
|
|
|
## |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Schedule::Chronic::Logger; |
8
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
141
|
|
9
|
1
|
|
|
1
|
|
7
|
use Errno qw(:POSIX); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
991
|
|
10
|
1
|
|
|
1
|
|
1769
|
use Data::Dumper; |
|
1
|
|
|
|
|
22607
|
|
|
1
|
|
|
|
|
129
|
|
11
|
1
|
|
|
1
|
|
1788
|
use Sys::Syslog qw(:DEFAULT setlogsock); |
|
1
|
|
|
|
|
29131
|
|
|
1
|
|
|
|
|
453
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Preloaded methods go here. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
|
my ($class, %args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my %self = (%args); |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
0
|
|
|
|
$self{facility} ||= 'daemon'; |
22
|
0
|
|
0
|
|
|
|
$self{name} ||= 'Chronic'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Open a connection to syslog over a UNIX socket. |
25
|
0
|
0
|
|
|
|
|
if ($args{type} eq 'syslog') { |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
openlog('Chronic', 'cons,pid', 'user'); |
28
|
0
|
|
|
|
|
|
setlogsock('unix'); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Syslog priorities and facilities. These are also used with |
33
|
|
|
|
|
|
|
# logging to STDERR. |
34
|
|
|
|
|
|
|
$self{syslog_priorities} = { |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
emerg => 0, |
37
|
|
|
|
|
|
|
alert => 1, |
38
|
|
|
|
|
|
|
crit => 2, |
39
|
|
|
|
|
|
|
err => 3, |
40
|
|
|
|
|
|
|
warning => 4, |
41
|
|
|
|
|
|
|
notice => 5, |
42
|
|
|
|
|
|
|
info => 6, |
43
|
|
|
|
|
|
|
debug => 7 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$self{syslog_facilities} = { |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
kern => 0, |
50
|
|
|
|
|
|
|
user => 1, |
51
|
|
|
|
|
|
|
mail => 2, |
52
|
|
|
|
|
|
|
daemon => 3, |
53
|
|
|
|
|
|
|
auth => 4, |
54
|
|
|
|
|
|
|
syslog => 5, |
55
|
|
|
|
|
|
|
lpr => 6, |
56
|
|
|
|
|
|
|
news => 7, |
57
|
|
|
|
|
|
|
uucp => 8, |
58
|
|
|
|
|
|
|
cron => 9, |
59
|
|
|
|
|
|
|
authpriv=> 10, |
60
|
|
|
|
|
|
|
ftp => 11, |
61
|
|
|
|
|
|
|
local0 => 16, |
62
|
|
|
|
|
|
|
local1 => 17, |
63
|
|
|
|
|
|
|
local2 => 18, |
64
|
|
|
|
|
|
|
local3 => 19, |
65
|
|
|
|
|
|
|
local4 => 20, |
66
|
|
|
|
|
|
|
local5 => 21, |
67
|
|
|
|
|
|
|
local6 => 22, |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return bless \%self, $class; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub logthis { |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
0
|
0
|
|
my ($self, $msg, $prio) = @_; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Default priority is 'debug' |
81
|
0
|
|
0
|
|
|
|
$prio ||= 'debug'; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if ($$self{type} eq 'syslog') { |
|
|
0
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
syslog("$$self{facility}|$prio", $msg); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} elsif ($$self{type} eq 'stderr') { |
88
|
0
|
|
|
|
|
|
$msg =~ s/^.+?:://; |
89
|
0
|
|
|
|
|
|
print STDERR "debug: $msg\n"; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |