| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Seshat; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1826
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
77
|
|
|
5
|
1
|
|
|
1
|
|
2069
|
use POSIX qw(strftime); |
|
|
1
|
|
|
|
|
18554
|
|
|
|
1
|
|
|
|
|
6
|
|
|
6
|
1
|
|
|
1
|
|
5468
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
38799
|
|
|
|
1
|
|
|
|
|
938
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
|
9
|
|
|
|
|
|
|
require AutoLoader; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader); |
|
12
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
|
13
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
14
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
15
|
|
|
|
|
|
|
@EXPORT = qw( |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
$VERSION = '1.1'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
|
21
|
0
|
|
|
0
|
1
|
|
my $classname = shift; |
|
22
|
0
|
|
|
|
|
|
my $filename = shift; |
|
23
|
0
|
|
|
|
|
|
my %params = @_; |
|
24
|
0
|
|
|
|
|
|
my $self = {}; |
|
25
|
0
|
|
|
|
|
|
$self->{NAME} = "Seshat"; |
|
26
|
0
|
|
|
|
|
|
$self->{FILE} = $filename; |
|
27
|
0
|
|
|
|
|
|
$self->{FLAG} = 0; |
|
28
|
0
|
|
|
|
|
|
$self->{POS} = 0; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# -> defaults -< # |
|
31
|
0
|
|
|
|
|
|
$self->{PARAM}->{LOG_LEVEL} = "0"; |
|
32
|
0
|
|
|
|
|
|
$self->{PARAM}->{DATE_FORMAT} ="%a %b %e %H:%M:%S %Y"; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
foreach (keys %params) { |
|
36
|
0
|
0
|
|
|
|
|
if (exists $self->{PARAM}->{$_}) { |
|
37
|
0
|
|
|
|
|
|
$self->{PARAM}->{$_} = $params{$_}; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
0
|
|
|
|
|
|
bless ($self,$classname); |
|
41
|
0
|
|
|
|
|
|
return $self; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub write { |
|
45
|
0
|
|
|
0
|
1
|
|
my ($self, $string, $flag) = @_; |
|
46
|
0
|
0
|
0
|
|
|
|
open(FH, ">>".$self->{FILE}) |
|
47
|
|
|
|
|
|
|
or ( $@="cant open ".$self->{FILE}.": $!" |
|
48
|
|
|
|
|
|
|
&& return undef); |
|
49
|
0
|
|
|
|
|
|
my $flocked = 0; |
|
50
|
0
|
|
|
|
|
|
while (! $flocked ) { |
|
51
|
0
|
0
|
|
|
|
|
if (! flock(FH, 2)) { |
|
52
|
0
|
|
|
|
|
|
sleep 1; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
else { |
|
55
|
0
|
|
|
|
|
|
$flocked = 1; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $print_string; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if ($self->{FLAG} eq 1) { seek(FH,$self->{POS},0) } # the line is not blank |
|
|
0
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
else { |
|
63
|
|
|
|
|
|
|
#$print_string = strftime "%a %b %e %H:%M:%S %Y", localtime; |
|
64
|
0
|
|
|
|
|
|
$print_string = strftime $self->{PARAM}->{DATE_FORMAT}, localtime; |
|
65
|
0
|
|
|
|
|
|
$print_string .= " : $0 : "; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
|
|
|
|
|
$print_string .= "$string"; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if ($flag eq 1) { # new line... |
|
|
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$print_string .= "\n"; |
|
71
|
0
|
|
|
|
|
|
print FH $print_string; |
|
72
|
0
|
|
|
|
|
|
$self->{FLAG} = 0; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
elsif ($flag eq 0) { #no new line... |
|
75
|
0
|
|
|
|
|
|
print FH $print_string; |
|
76
|
0
|
|
|
|
|
|
$self->{FLAG} = 1; |
|
77
|
0
|
|
|
|
|
|
my $index = tell(FH); |
|
78
|
0
|
|
|
|
|
|
$self->{POS} = $index; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
0
|
0
|
|
|
|
close(FH) |
|
82
|
|
|
|
|
|
|
or ($@= "can't close $!" |
|
83
|
|
|
|
|
|
|
&& return undef); |
|
84
|
0
|
|
|
|
|
|
return 1; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
|
88
|
|
|
|
|
|
|
__END__ |