Ignore:
Timestamp:
2017-02-14T17:43:28+13:00 (7 years ago)
Author:
ak19
Message:

Adding verbosity setting to oaiinfo.pm to reduce debug output on regular runs of building process. The perl filest that use oaiinfo now pass in the verbosity setting to the oaiinfo constructor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/oaiinfo.pm

    r31218 r31409  
    2828sub new {
    2929    my $class = shift(@_);
    30     my ($config_filename, $infodbtype) = @_;
     30    my ($config_filename, $infodbtype, $verbosity) = @_;
    3131 
    3232    my $self = {
     33    'verbosity' => $verbosity || 0,
     34    'verbosity_threshold' => 5, # start printing debugging info from verbosity >= threshold
    3335    'info'=>{} # map of {OID, array[deletion-status,timestamp,datestamp]} pairs
    3436    };
     
    4749    $self->{'oaidb_tmp_filepath'} = &dbutil::get_infodb_file_path($infodbtype, "oai-inf-tmp", $etc_dir, $perform_firsttime_init);
    4850    $self->{'etc_dir'} = $etc_dir;
    49 #    print STDERR "############ LIVE DB: $self->{'oaidb_live_filepath'}\n";
    50 #    print STDERR "############ TMP DB: $self->{'oaidb_tmp_filepath'}\n";
     51#    print STDERR "############ LIVE DB: $self->{'oaidb_live_filepath'}\n" if $self->{'verbosity'} >= $self->{'verbosity_threshold'};
     52#    print STDERR "############ TMP DB: $self->{'oaidb_tmp_filepath'}\n" if $self->{'verbosity'} >= $self->{'verbosity_threshold'};
    5153
    5254    $self->{'oaidb_file_path'} = $self->{'oaidb_tmp_filepath'}; # db file we're working with
     
    184186                                 # final param follows jmt's $perform_firsttime_init in inexport.pm
    185187
    186 #    print STDERR "@@@@@ oaidb: $self->{'oaidb_file_path'}\n";
     188#    print STDERR "@@@@@ oaidb: $self->{'oaidb_file_path'}\n" if $self->{'verbosity'} >= $self->{'verbosity_threshold'};
    187189   
    188190    return $do_pd_step;
     
    197199    my $self = shift (@_);
    198200    my ($removeold, $have_manifest) = @_;
    199    
     201   
    200202    my $do_pd_step = $self->init_tmpdb($removeold, $have_manifest);
    201203      # returns 1 if the step to mark oaidb entries as PD is required
     
    244246                 # see http://perldoc.perl.org/constant.html
    245247
    246     print STDERR "######## OID: $OID - status: $indexing_status\n";
     248    print STDERR "######## OID: $OID - status: $indexing_status\n" if $self->{'verbosity'} >= $self->{'verbosity_threshold'};
    247249
    248250    if($indexing_status eq "I") {
     
    257259        # an oaicollection. But what if we always maintain an oaidb? Still call $self->index() here.
    258260    } else {
    259         print STDERR "### oaiinfo::building_stage_before_indexing(): Unrecognised indexing status $indexing_status\n";
     261        if ($self->{'verbosity'} >= $self->{'verbosity_threshold'}) {
     262            print STDERR "### oaiinfo::building_stage_before_indexing(): Unrecognised indexing status $indexing_status\n";
     263        }
    260264    }
    261265    }
     
    288292    &dbutil::rename_db_file_to($self->{'infodbtype'}, $oaidb_tmp_filepath, $oaidb_live_filepath); # rename the db file and any assoc files
    289293
    290     print STDERR "#### Should now have MOVED $self->{'oaidb_tmp_filepath'} to $self->{'oaidb_live_filepath'}\n";
     294    if ($self->{'verbosity'} >= $self->{'verbosity_threshold'}) {
     295        print STDERR "#### Should now have MOVED $self->{'oaidb_tmp_filepath'} to $self->{'oaidb_live_filepath'}\n";
     296    }
    291297   
    292298    } else {
    293     print STDERR "@@@@@ In oaiinfo::activate_collection():\n";
    294     print STDERR "@@@@@   No tmpdb at $self->{'oaidb_tmp_filepath'}\n";
    295     print STDERR "@@@@@   to make 'live' by moving to $self->{'oaidb_live_filepath'}.\n";
     299        if ($self->{'verbosity'} >= $self->{'verbosity_threshold'}) {
     300            print STDERR "@@@@@ In oaiinfo::activate_collection():\n";
     301            print STDERR "@@@@@   No tmpdb at $self->{'oaidb_tmp_filepath'}\n";
     302            print STDERR "@@@@@   to make 'live' by moving to $self->{'oaidb_live_filepath'}.\n";
     303        }
    296304    }
    297305}
     
    306314    my $self = shift (@_);
    307315   
    308     print STDERR "@@@@@ oaiinfo::mark_all_E_as_PD(): Marking the E entries as PD\n";
     316    print STDERR "@@@@@ oaiinfo::mark_all_E_as_PD(): Marking the E entries as PD\n" if $self->{'verbosity'} >= $self->{'verbosity_threshold'};
    309317
    310318    my $infomap = $self->{'info'};
     
    324332    my $self = shift (@_);
    325333   
    326     print STDERR "@@@@@ oaiinfo::mark_all_PD_as_D(): Marking the PD entries as D\n";
     334    print STDERR "@@@@@ oaiinfo::mark_all_PD_as_D(): Marking the PD entries as D\n" if $self->{'verbosity'} >= $self->{'verbosity_threshold'};
    327335
    328336    my $infomap = $self->{'info'};
     
    343351    my $self = shift (@_);
    344352
     353    if ($self->{'verbosity'} < $self->{'verbosity_threshold'}) {
     354        return;
     355    }   
     356   
    345357    print STDERR "###########################################################\n";
    346358    print STDERR "@@@@@ oaiinfo::print_info(): oaidb in memory contains: \n";
Note: See TracChangeset for help on using the changeset viewer.