Commit a716073e8ef20be1d53aa8bf092f2187613c1b09

Authored by conradverm
1 parent b19603ad

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,16 +306,14 @@ abstract class Indexer
306 */ 306 */
307 protected function __construct() 307 protected function __construct()
308 { 308 {
309 - $this->extractorCache=array();  
310 - $this->debug=true;  
311 - $this->hookCache = array();  
312 - $this->generalHookCache = array();  
313 -  
314 $config = KTConfig::getSingleton(); 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 $this->loadExtractorStatus(); 318 $this->loadExtractorStatus();
321 } 319 }
@@ -383,7 +381,7 @@ abstract class Indexer @@ -383,7 +381,7 @@ abstract class Indexer
383 $sql = "delete from mime_extractors"; 381 $sql = "delete from mime_extractors";
384 DBUtil::runQuery($sql); 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,7 +451,7 @@ abstract class Indexer
453 $sql = "INSERT INTO index_files(document_id, user_id, what) VALUES($document_id, $userid, '$what')"; 451 $sql = "INSERT INTO index_files(document_id, user_id, what) VALUES($document_id, $userid, '$what')";
454 DBUtil::runQuery($sql); 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,7 +485,7 @@ abstract class Indexer
487 );'; 485 );';
488 DBUtil::runQuery($sql); 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,7 +677,7 @@ abstract class Indexer
679 { 677 {
680 return; 678 return;
681 } 679 }
682 - $default->log->info('checkForRegisteredTypes: start'); 680 + if ($this->debug) $default->log->debug('checkForRegisteredTypes: start');
683 681
684 $date = date('Y-m-d H:i'); 682 $date = date('Y-m-d H:i');
685 $sql = "UPDATE scheduler_tasks SET run_time='$date'"; 683 $sql = "UPDATE scheduler_tasks SET run_time='$date'";
@@ -701,7 +699,7 @@ abstract class Indexer @@ -701,7 +699,7 @@ abstract class Indexer
701 $default->log->info("checkForRegisteredTypes: disabled '$extractor'"); 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 KTUtil::setSystemSetting('mimeTypesRegistered', true); 703 KTUtil::setSystemSetting('mimeTypesRegistered', true);
706 } 704 }
707 705
@@ -728,10 +726,11 @@ abstract class Indexer @@ -728,10 +726,11 @@ abstract class Indexer
728 726
729 $this->checkForRegisteredTypes(); 727 $this->checkForRegisteredTypes();
730 728
731 - $default->log->info('indexDocuments: start'); 729 + if ($this->debug) $default->log->debug('indexDocuments: start');
732 if (!$this->doesDiagnosticsPass()) 730 if (!$this->doesDiagnosticsPass())
733 { 731 {
734 //unlink($indexLockFile); 732 //unlink($indexLockFile);
  733 + if ($this->debug) $default->log->debug('indexDocuments: stopping - diagnostics problem. The dashboard will provide more information.');
735 return; 734 return;
736 } 735 }
737 736
@@ -764,6 +763,7 @@ abstract class Indexer @@ -764,6 +763,7 @@ abstract class Indexer
764 if (PEAR::isError($result)) 763 if (PEAR::isError($result))
765 { 764 {
766 //unlink($indexLockFile); 765 //unlink($indexLockFile);
  766 + if ($this->debug) $default->log->debug('indexDocuments: stopping - db error');
767 return; 767 return;
768 } 768 }
769 769
@@ -771,6 +771,7 @@ abstract class Indexer @@ -771,6 +771,7 @@ abstract class Indexer
771 if (count($result) == 0) 771 if (count($result) == 0)
772 { 772 {
773 //unlink($indexLockFile); 773 //unlink($indexLockFile);
  774 + if ($this->debug) $default->log->debug('indexDocuments: stopping - no work to be done');
774 return; 775 return;
775 } 776 }
776 777
@@ -804,17 +805,12 @@ abstract class Indexer @@ -804,17 +805,12 @@ abstract class Indexer
804 805
805 if ($this->debug) 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 if (empty($extractorClass)) 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 continue; 814 continue;
819 } 815 }
820 816
@@ -867,8 +863,7 @@ abstract class Indexer @@ -867,8 +863,7 @@ abstract class Indexer
867 863
868 if (empty($sourceFile) || !is_file($sourceFile)) 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 continue; 867 continue;
873 } 868 }
874 869
@@ -896,10 +891,8 @@ abstract class Indexer @@ -896,10 +891,8 @@ abstract class Indexer
896 $extractor->setDocument($document); 891 $extractor->setDocument($document);
897 $extractor->setIndexingStatus(null); 892 $extractor->setIndexingStatus(null);
898 $extractor->setExtractionStatus(null); 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 $this->executeHook($extractor, 'pre_extract'); 897 $this->executeHook($extractor, 'pre_extract');
905 $this->executeHook($extractor, 'pre_extract', $mimeType); 898 $this->executeHook($extractor, 'pre_extract', $mimeType);
@@ -971,15 +964,14 @@ abstract class Indexer @@ -971,15 +964,14 @@ abstract class Indexer
971 964
972 if ($removeFromQueue) 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 //unlink($indexLockFile); 975 //unlink($indexLockFile);
984 } 976 }
985 977
@@ -1176,7 +1168,7 @@ abstract class Indexer @@ -1176,7 +1168,7 @@ abstract class Indexer
1176 1168
1177 if (!$this->isExtractorEnabled($class)) 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 continue; 1172 continue;
1181 } 1173 }
1182 1174
@@ -1263,10 +1255,15 @@ abstract class Indexer @@ -1263,10 +1255,15 @@ abstract class Indexer
1263 * 1255 *
1264 * @param int $docid 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 $sql = "DELETE FROM index_files WHERE document_id=$docid"; 1260 $sql = "DELETE FROM index_files WHERE document_id=$docid";
1269 DBUtil::runQuery($sql); 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 /**