Commit 042dbb991905e3c56e3c803e50db471f4a72f8f0

Authored by Conrad Vermeulen
1 parent c4bab430

KTS-2641

"indexing task should log start and stop as debug"
Fixed.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7663 c91229c3-7414-0410-bfa2-8a42b809f60b
search2/indexing/indexerCore.inc.php
... ... @@ -306,16 +306,14 @@ abstract class Indexer
306 306 */
307 307 protected function __construct()
308 308 {
309   - $this->extractorCache=array();
310   - $this->debug=true;
311   - $this->hookCache = array();
312   - $this->generalHookCache = array();
313   -
314 309 $config = KTConfig::getSingleton();
315 310  
316   - $this->extractorPath = $config->get('indexer/extractorPath', 'extractors');
317   - $this->hookPath = $config->get('indexer/extractorHookPath','extractorHooks');
318   -
  311 + $this->extractorCache = array();
  312 + $this->debug = $config->get('indexer/debug', true);
  313 + $this->hookCache = array();
  314 + $this->generalHookCache = array();
  315 + $this->extractorPath = $config->get('indexer/extractorPath', 'extractors');
  316 + $this->hookPath = $config->get('indexer/extractorHookPath','extractorHooks');
319 317  
320 318 $this->loadExtractorStatus();
321 319 }
... ... @@ -383,7 +381,7 @@ abstract class Indexer
383 381 $sql = "delete from mime_extractors";
384 382 DBUtil::runQuery($sql);
385 383  
386   - $default->log->debug('clearExtractors');
  384 + if ($this->debug) $default->log->debug('clearExtractors');
387 385 }
388 386  
389 387 /**
... ... @@ -453,7 +451,7 @@ abstract class Indexer
453 451 $sql = "INSERT INTO index_files(document_id, user_id, what) VALUES($document_id, $userid, '$what')";
454 452 DBUtil::runQuery($sql);
455 453  
456   -// if ($this->debug) $default->log->debug("index: Queuing indexing of $document_id");
  454 + if ($this->debug) $default->log->debug("index: Queuing indexing of $document_id");
457 455 }
458 456  
459 457  
... ... @@ -487,7 +485,7 @@ abstract class Indexer
487 485 );';
488 486 DBUtil::runQuery($sql);
489 487  
490   - // if ($this->debug) $default->log->debug("clearoutDeleted: remove documents");
  488 + $default->log->debug("Indexer::clearoutDeleted: removed documents from indexing queue that have been deleted");
491 489 }
492 490  
493 491  
... ... @@ -679,7 +677,7 @@ abstract class Indexer
679 677 {
680 678 return;
681 679 }
682   - $default->log->info('checkForRegisteredTypes: start');
  680 + if ($this->debug) $default->log->debug('checkForRegisteredTypes: start');
683 681  
684 682 $date = date('Y-m-d H:i');
685 683 $sql = "UPDATE scheduler_tasks SET run_time='$date'";
... ... @@ -701,7 +699,7 @@ abstract class Indexer
701 699 $default->log->info("checkForRegisteredTypes: disabled '$extractor'");
702 700 }
703 701  
704   - $default->log->info('checkForRegisteredTypes: done');
  702 + if ($this->debug) $default->log->debug('checkForRegisteredTypes: done');
705 703 KTUtil::setSystemSetting('mimeTypesRegistered', true);
706 704 }
707 705  
... ... @@ -728,10 +726,11 @@ abstract class Indexer
728 726  
729 727 $this->checkForRegisteredTypes();
730 728  
731   - $default->log->info('indexDocuments: start');
  729 + if ($this->debug) $default->log->debug('indexDocuments: start');
732 730 if (!$this->doesDiagnosticsPass())
733 731 {
734 732 //unlink($indexLockFile);
  733 + if ($this->debug) $default->log->debug('indexDocuments: stopping - diagnostics problem. The dashboard will provide more information.');
735 734 return;
736 735 }
737 736  
... ... @@ -764,6 +763,7 @@ abstract class Indexer
764 763 if (PEAR::isError($result))
765 764 {
766 765 //unlink($indexLockFile);
  766 + if ($this->debug) $default->log->debug('indexDocuments: stopping - db error');
767 767 return;
768 768 }
769 769  
... ... @@ -771,6 +771,7 @@ abstract class Indexer
771 771 if (count($result) == 0)
772 772 {
773 773 //unlink($indexLockFile);
  774 + if ($this->debug) $default->log->debug('indexDocuments: stopping - no work to be done');
774 775 return;
775 776 }
776 777  
... ... @@ -804,17 +805,12 @@ abstract class Indexer
804 805  
805 806 if ($this->debug)
806 807 {
807   - $default->log->debug(sprintf(_kt("Indexing docid: %d extension: '%s' mimetype: '%s' extractor: '%s'"), $docId, $extension,$mimeType,$extractorClass));
  808 + if ($this->debug) $default->log->debug(sprintf(_kt("Indexing docid: %d extension: '%s' mimetype: '%s' extractor: '%s'"), $docId, $extension,$mimeType,$extractorClass));
808 809 }
809 810  
810 811 if (empty($extractorClass))
811 812 {
812   - if ($this->debug)
813   - {
814   - $default->log->debug(sprintf(_kt("No extractor for docid: %d"),$docId));
815   - }
816   -
817   - Indexer::unqueueDocument($docId);
  813 + Indexer::unqueueDocument($docId, sprintf(_kt("No extractor for docid: %d"),$docId));
818 814 continue;
819 815 }
820 816  
... ... @@ -867,8 +863,7 @@ abstract class Indexer
867 863  
868 864 if (empty($sourceFile) || !is_file($sourceFile))
869 865 {
870   - $default->log->error(sprintf(_kt("indexDocuments: source file '%s' for document %d does not exist."),$sourceFile,$docId));
871   - Indexer::unqueueDocument($docId);
  866 + Indexer::unqueueDocument($docId,sprintf(_kt("indexDocuments: source file '%s' for document %d does not exist."),$sourceFile,$docId), 'error');
872 867 continue;
873 868 }
874 869  
... ... @@ -896,10 +891,8 @@ abstract class Indexer
896 891 $extractor->setDocument($document);
897 892 $extractor->setIndexingStatus(null);
898 893 $extractor->setExtractionStatus(null);
899   - if ($this->debug)
900   - {
901   - $default->log->debug(sprintf(_kt("Extra Info docid: %d Source File: '%s' Target File: '%s'"),$docId,$sourceFile,$targetFile));
902   - }
  894 +
  895 + if ($this->debug) $default->log->debug(sprintf(_kt("Extra Info docid: %d Source File: '%s' Target File: '%s'"),$docId,$sourceFile,$targetFile));
903 896  
904 897 $this->executeHook($extractor, 'pre_extract');
905 898 $this->executeHook($extractor, 'pre_extract', $mimeType);
... ... @@ -971,15 +964,14 @@ abstract class Indexer
971 964  
972 965 if ($removeFromQueue)
973 966 {
974   - Indexer::unqueueDocument($docId);
  967 + Indexer::unqueueDocument($docId, sprintf(_kt("Done indexing docid: %d"),$docId));
  968 + }
  969 + else
  970 + {
  971 + if ($this->debug) $default->log->debug(sprintf(_kt("Document docid: %d was not removed from the queue as it looks like there was a problem with the extraction process"),$docId));
975 972 }
976   - if ($this->debug)
977   - {
978   - $default->log->debug(sprintf(_kt("Done indexing docid: %d"),$docId));
979   - }
980   -
981 973 }
982   - $default->log->info('indexDocuments: done');
  974 + if ($this->debug) $default->log->debug('indexDocuments: done');
983 975 //unlink($indexLockFile);
984 976 }
985 977  
... ... @@ -1176,7 +1168,7 @@ abstract class Indexer
1176 1168  
1177 1169 if (!$this->isExtractorEnabled($class))
1178 1170 {
1179   - $default->log->info(sprintf(_kt("diagnose: extractor '%s' is disabled."), $class));
  1171 + $default->log->debug(sprintf(_kt("diagnose: extractor '%s' is disabled."), $class));
1180 1172 continue;
1181 1173 }
1182 1174  
... ... @@ -1263,10 +1255,15 @@ abstract class Indexer
1263 1255 *
1264 1256 * @param int $docid
1265 1257 */
1266   - public static function unqueueDocument($docid)
  1258 + public static function unqueueDocument($docid, $reason=false, $level='debug')
1267 1259 {
1268 1260 $sql = "DELETE FROM index_files WHERE document_id=$docid";
1269 1261 DBUtil::runQuery($sql);
  1262 + if ($reason !== false)
  1263 + {
  1264 + global $default;
  1265 + $default->log->$level("Indexer: removing document $docid from the queue - $reason");
  1266 + }
1270 1267 }
1271 1268  
1272 1269 /**
... ...