line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
## Emacs: -*- tab-width: 4; -*- |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
125839
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
71
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Data::CTable::ProgressLogger; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=pod |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Data::CTable::ProgressLogger - CTable that stores messages in the object |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $Table = Data::CTable::ProgressLogger->new("mydata.txt"); |
17
|
|
|
|
|
|
|
# ... do stuff... |
18
|
|
|
|
|
|
|
$Table->write(); |
19
|
|
|
|
|
|
|
$Table->show_log(); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 OVERVIEW |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
ProgressLogger is a subclass of Data::CTable. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
The only difference is that it enables per-instance progress by |
26
|
|
|
|
|
|
|
defaul, but it stores progress messages in the object instead of |
27
|
|
|
|
|
|
|
sending them to STDERR. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Later, they can be gotten in an array by calling the log() method |
30
|
|
|
|
|
|
|
or dumped with show_log(). |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
2298
|
use Data::CTable; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
35
|
1
|
|
|
1
|
|
7
|
use vars qw(@ISA); @ISA=qw(Data::CTable); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
300
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub initialize ## Add a new param; change one default |
38
|
|
|
|
|
|
|
{ |
39
|
1
|
|
|
1
|
0
|
3
|
my $this = shift; |
40
|
1
|
50
|
|
|
|
14
|
$this->{_Progress} = 1 unless exists($this->{_Progress}); |
41
|
1
|
|
50
|
|
|
7
|
$this->{_ProgrLog} ||= []; |
42
|
1
|
|
|
|
|
10
|
$this->SUPER::initialize(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub progress_default ## Log message to object's ProgMsgs list |
46
|
|
|
|
|
|
|
{ |
47
|
2
|
|
|
2
|
0
|
3
|
my $this = shift; |
48
|
2
|
|
|
|
|
3
|
my ($msg) = @_; |
49
|
2
|
|
|
|
|
11
|
chomp $msg; |
50
|
2
|
|
|
|
|
2
|
push @{$this->{_ProgrLog}}, localtime() . " $msg"; |
|
2
|
|
|
|
|
175
|
|
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
8
|
return(1); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub log |
56
|
|
|
|
|
|
|
{ |
57
|
1
|
|
|
1
|
0
|
7
|
my $this = shift; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
9
|
return($this->{_ProgrLog}); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub show_log ## Use Dumper to spit out the log list |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
0
|
0
|
|
my $this = shift; |
65
|
0
|
|
|
|
|
|
$this->dump($this->log()); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |