| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
################################################################################ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# $Id: LogDir.pm 211 2009-05-25 06:05:50Z aijaz $ |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
################################################################################ |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
TaskForest::LogDir - Functions related to today's log directory |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use TaskForest::LogDir; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $log_dir = &TaskForest::LogDir::getLogDir("/var/logs/taskforest"); |
|
16
|
|
|
|
|
|
|
# $log_dir is created if it does not exist |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DOCUMENTATION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
If you're just looking to use the taskforest application, the only |
|
21
|
|
|
|
|
|
|
documentation you need to read is that for TaskForest. You can do this |
|
22
|
|
|
|
|
|
|
either of the two ways: |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
perldoc TaskForest |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
OR |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
man TaskForest |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This is a simple package that provides a location for the getLogDir |
|
33
|
|
|
|
|
|
|
function that's used in a few places. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
package TaskForest::LogDir; |
|
40
|
94
|
|
|
94
|
|
189578
|
use strict; |
|
|
94
|
|
|
|
|
214
|
|
|
|
94
|
|
|
|
|
5094
|
|
|
41
|
94
|
|
|
94
|
|
572
|
use warnings; |
|
|
94
|
|
|
|
|
190
|
|
|
|
94
|
|
|
|
|
3363
|
|
|
42
|
94
|
|
|
94
|
|
549
|
use Carp; |
|
|
94
|
|
|
|
|
192
|
|
|
|
94
|
|
|
|
|
9169
|
|
|
43
|
94
|
|
|
94
|
|
2133
|
use TaskForest::LocalTime; |
|
|
94
|
|
|
|
|
198
|
|
|
|
94
|
|
|
|
|
3055
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
BEGIN { |
|
46
|
94
|
|
|
94
|
|
658
|
use vars qw($VERSION); |
|
|
94
|
|
|
|
|
171
|
|
|
|
94
|
|
|
|
|
4738
|
|
|
47
|
94
|
|
|
94
|
|
23126
|
$VERSION = '1.30'; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $log_dir_cached; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
53
|
|
|
|
|
|
|
=pod |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item getLogDir() |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Usage : my $log_dir = TaskForest::LogDir::getLogDir($root) |
|
60
|
|
|
|
|
|
|
Purpose : This method creates a dated subdirectory of its first |
|
61
|
|
|
|
|
|
|
parameter, if that directory doesn't already exist. |
|
62
|
|
|
|
|
|
|
Returns : The dated directory |
|
63
|
|
|
|
|
|
|
Argument : $root - the parent directory of the dated directory |
|
64
|
|
|
|
|
|
|
$tz - the timezone of the family, that determines the date |
|
65
|
|
|
|
|
|
|
$reload - If this is true, and we have a cached value, |
|
66
|
|
|
|
|
|
|
return the cached value |
|
67
|
|
|
|
|
|
|
Throws : "mkdir $log_dir failed" if the log directory cannot be |
|
68
|
|
|
|
|
|
|
created |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------ |
|
75
|
|
|
|
|
|
|
sub getLogDir { |
|
76
|
615
|
|
|
615
|
1
|
114733
|
my ($log_dir_root, $tz, $reload) = @_; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#if ($log_dir_cached and !$reload) { |
|
79
|
|
|
|
|
|
|
# return $log_dir_cached; |
|
80
|
|
|
|
|
|
|
#} |
|
81
|
|
|
|
|
|
|
|
|
82
|
615
|
|
|
|
|
1143
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); |
|
83
|
615
|
100
|
|
|
|
19260
|
if ($tz) { |
|
84
|
500
|
|
|
|
|
2177
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = &TaskForest::LocalTime::ft($tz); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
else { |
|
87
|
115
|
|
|
|
|
1131
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = &TaskForest::LocalTime::lt(); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
615
|
|
|
|
|
22066
|
my $log_dir = sprintf("$log_dir_root/%4d%02d%02d", $year, $mon, $mday); |
|
91
|
615
|
100
|
|
|
|
30579
|
unless (-d $log_dir) { |
|
92
|
2
|
50
|
|
|
|
173
|
if (mkdir $log_dir) { |
|
93
|
|
|
|
|
|
|
# do nothing - succeeded |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
else { |
|
96
|
0
|
|
|
|
|
0
|
croak "mkdir $log_dir failed in LogDir::getLogDir!\n"; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
#$log_dir_cached = $log_dir; |
|
100
|
615
|
|
|
|
|
2657
|
return $log_dir; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |