Changeset 31409

Show
Ignore:
Timestamp:
14.02.2017 17:43:28 (3 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.

Location:
main/trunk/greenstone2
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/activate.pl

    r31190 r31409  
    358358 
    359359    # now we've moved building to index, move tmp oaidb to live oaidb in parallel 
    360     my $oai_info = new oaiinfo($collect_cfg_filename, $collectcfg->{'infodbtype'}); 
     360    my $oai_info = new oaiinfo($collect_cfg_filename, $collectcfg->{'infodbtype'}, $default_verbosity); 
    361361    $oai_info->activate_collection(); 
    362362 
  • main/trunk/greenstone2/perllib/basebuilder.pm

    r31190 r31409  
    183183     
    184184    my $archivedir = $self->{'source_dir'}; 
    185     my $oai_info = new oaiinfo($self->{'colcfgname'}, $self->{'collect_cfg'}->{'infodbtype'});     
     185    my $oai_info = new oaiinfo($self->{'colcfgname'}, $self->{'collect_cfg'}->{'infodbtype'}, $self->{'verbosity'});     
    186186    $oai_info->building_stage_before_indexing($archivedir); 
    187187 
  • main/trunk/greenstone2/perllib/inexport.pm

    r31191 r31409  
    734734    # Prepare to work with the <collection>/etc/oai-inf.<db> that keeps track 
    735735    # of the OAI identifiers with their time stamps and deleted status.     
    736     my $oai_info = new oaiinfo($self->{'config_filename'}, $collectcfg->{'infodbtype'}); 
     736    my $oai_info = new oaiinfo($self->{'config_filename'}, $collectcfg->{'infodbtype'}, $verbosity); 
    737737    my $have_manifest = ($manifest eq '') ? 0 : 1;     
    738738    $oai_info->import_stage($removeold, $have_manifest); 
  • 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";