root/lib/basiclog.pm

Revision 259, 1.4 kB (checked in by cholt, 3 months ago)

mpi_iprscan more maker like behavior

Line 
1 #-------------------------------------------------------------------------------
2 #------                           runlog                               ---------
3 #-------------------------------------------------------------------------------
4 package basiclog;
5 use strict;
6 use vars qw(@ISA @EXPORT $VERSION %SEEN);
7 use Exporter;
8
9 @ISA = qw();
10
11 #-------------------------------------------------------------------------------
12 #------------------------------- Methods ---------------------------------------
13 #-------------------------------------------------------------------------------
14 sub new {
15     my $self = {};
16     my $class = shift;
17
18     bless ($self, $class);
19
20     my $file = shift || "run.log";
21     $self->{file} = $file;
22
23     open(my $OUT, "> $file");
24     close($OUT);
25
26     return $self;
27 }
28 #-------------------------------------------------------------------------------
29 sub add_entry {
30    my $self = shift;
31
32    my @vals = @_;
33    
34    foreach my $val (@vals){
35        chomp($val);
36    }
37
38    my $log_file = $self->{file};
39
40    open(LOG, ">> $log_file");
41    print LOG join("\t", @vals)."\n";
42    close(LOG);
43 }
44 #-------------------------------------------------------------------------------
45 sub continue_flag {
46    my $self = shift;
47    my $id = shift;
48
49    $SEEN{$id}++;
50
51    my $flag = 0;
52    $flag = 1 if($SEEN{$id} <= 2); #retry only once
53
54    return $flag;
55 }
56 #-------------------------------------------------------------------------------
57 1;
Note: See TracBrowser for help on using the browser.