Changeset 25486


Ignore:
Timestamp:
04/26/12 12:39:28 (9 years ago)
Author:
jmt12
Message:

Making calls to debugPrint a little cheaper when debugging disabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb-edit/trunk/src/bin/script/TDBServer.pl

    r25477 r25486  
    8282my $collection = '';
    8383my $no_daemon = 0;
    84 my $debug = 1;
     84my $debug = 0;
    8585my $server;
    8686my $server_host;
     
    326326    # //unlock($msg_counter);
    327327  }
    328   &debugPrint($the_count, $tid, 'RECV', $data);
     328  &debugPrint($the_count, $tid, 'RECV', $data) unless !$debug;
    329329  # process special commands first
    330330  if ($data =~ /^#([arq]):(.*)$/)
     
    417417    my $payload = $4;
    418418    $payload =~ s/^\s+|\s+$//g;
    419     &debugPrint($the_count, $tid, 'PARSED', 'database=' . $database . ', key=' . $key . ', action=' . $action . ', payload=' . $payload);
     419    &debugPrint($the_count, $tid, 'PARSED', 'database=' . $database . ', key=' . $key . ', action=' . $action . ', payload=' . $payload) unless !$debug;
    420420    # Build path to database file
    421421    my $tdb_path = '';
     
    438438      my $record = '[' . $key . ']' . $action . $payload;
    439439      # Open harness to TDBCLI
    440       &debugPrint($the_count, $tid, 'TDBCLI', 'Opening harness');
     440      &debugPrint($the_count, $tid, 'TDBCLI', 'Opening harness') unless !$debug;
    441441      my @tdb_command = ($tdbexe, $tdb_path, '-mid ' . $the_count);
    442442      my $buffer_to_tdb = '';
     
    455455      }
    456456      # - read any response from TDBCLI
    457       &debugPrint($the_count, $tid, 'TDBCLI', 'Reading');
     457      &debugPrint($the_count, $tid, 'TDBCLI', 'Reading') unless !$debug;
    458458      while ($buffer_from_tdb !~ /-{70}/)
    459459      {
     
    461461      }
    462462      # - explicitly tell the pipe to quit (empty key)
    463       &debugPrint($the_count, $tid, 'TDBCLI', 'Closing');
     463      &debugPrint($the_count, $tid, 'TDBCLI', 'Closing') unless !$debug;
    464464      $buffer_to_tdb = "[]\n";
    465465      while (length($buffer_to_tdb))
     
    472472      chomp($result);
    473473      # Finished with harness
    474       &debugPrint($the_count, $tid, 'TDBCLI', 'Finishing harness');
     474      &debugPrint($the_count, $tid, 'TDBCLI', 'Finishing harness') unless !$debug;
    475475      finish($tdb_harness);
    476       &debugPrint($the_count, $tid, 'TDBCLI', 'Complete');
     476      &debugPrint($the_count, $tid, 'TDBCLI', 'Complete') unless !$debug;
    477477    }
    478478    # Use different TDB tools depending on arguments
     
    493493        $command1 = 'tdbget "' . $tdb_path . '" "' . $key . '"';
    494494      }
    495       &debugPrint($the_count, $tid, $command_name, 'Command: ' . $command1);
     495      &debugPrint($the_count, $tid, $command_name, 'Command: ' . $command1) unless !$debug;
    496496      $result = `$command1`;
    497       &debugPrint($the_count, $tid, $command_name, 'Result: ' . $result);
     497      &debugPrint($the_count, $tid, $command_name, 'Result: ' . $result) unless !$debug;
    498498      if ($result =~ /-{70}/)
    499499      {
     
    505505    {
    506506      my $command2 = 'txt2tdb -append "' . $tdb_path . '"';
    507       &debugPrint($the_count, $tid, 'TXT2TDB', 'Command: ' . $command2);
     507      &debugPrint($the_count, $tid, 'TXT2TDB', 'Command: ' . $command2) unless !$debug;
    508508      open(my $infodb_handle, '| ' . $command2) or die("Error! Failed to open pipe to TXT2TDB\n");
    509509      print $infodb_handle '[' . $key . ']';
     
    515515      close($infodb_handle);
    516516      $result = "-"x70 . "\n";
    517       &debugPrint($the_count, $tid, 'TXT2TDB', 'Result: ' . $result);
     517      &debugPrint($the_count, $tid, 'TXT2TDB', 'Result: ' . $result) unless !$debug;
    518518    }
    519519    else
     
    523523  }
    524524  # Synchronized debug log writing
    525   &debugPrint($the_count, $tid, 'SEND', $result);
     525  &debugPrint($the_count, $tid, 'SEND', $result) unless !$debug;
    526526  return $result;
    527527}
Note: See TracChangeset for help on using the changeset viewer.