IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17281


Ignore:
Timestamp:
Apr 2, 2008, 12:02:03 PM (18 years ago)
Author:
jhoblitt
Message:

fix filtering
fix handling of corrupted records & times
improved error messages
die if corrupted records make it through the parse phase

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/arclog/arclog.pl

    r17272 r17281  
    1919pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    2020
    21 my $filter_records = 1;
     21my $filter_records = 0;
    2222
    2323my $rcfile = "$ENV{HOME}/.arclogrc";
     
    5454    my $res = $ua->request(HTTP::Request->new(GET => "http://$hostport/"));
    5555    unless ($res->is_success) {
    56         warn $res->status_line;
     56        warn "can't access $hostport: ", $res->status_line;
    5757        next;
    5858    }
     
    7171    $res= $ua->request($req);
    7272    unless ($res->is_success) {
    73         die $res->status_line;
     73        die "can't access $hostport: ", $res->status_line;
    7474    }
    7575
     
    132132}
    133133
    134 #use Data::Dumper;
     134use Data::Dumper;
    135135#print Dumper(\@records);
    136136# sort by time
    137137# insert all records
    138 @records = sort { $a->{time} cmp $b->{time} } @records;
     138@records = sort {
     139    unless (defined $a->{time} && defined $b->{time}) {
     140        print Dumper($a);
     141        print Dumper($b);
     142    }
     143    $a->{time} cmp $b->{time}
     144} @records;
    139145my $query = $dbh->prepare("INSERT OR IGNORE INTO log VALUES(?)")
    140146        or die "database error: $!";
     
    155161
    156162    # do not print filtered records
    157     if (defined $filter_records) {
     163    if ($filter_records) {
    158164        foreach my $filter (@myfilters) {
    159165            next RECORDS if $event =~ /$filter/;
     
    191197    @row_data{qw( time device event elapse_time errors )} = @fields;
    192198
     199    # ipp008 has been returning valid rows with completely empty fields
     200    return unless defined $row_data{time};
     201
    193202    # parse time string into a DateTime object for easy sorting later
    194     $row_data{time} = $strptime->parse_datetime($row_data{time});
     203    my $dt = $strptime->parse_datetime($row_data{time});
     204
     205    unless (defined $dt) {
     206#        warn "can't parse time string $row_data{time}";
     207        return;
     208    }
     209
     210    $row_data{time} = $dt;
    195211
    196212    return \%row_data;
Note: See TracChangeset for help on using the changeset viewer.