Skip to content

Commit f6c06fd

Browse files
committed
TASK: Further improve logging of indexing progress/tasks
1 parent 1116b00 commit f6c06fd

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

  • Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer/NodeIndexer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null)
255255
$this->updateFulltext($node, $fulltextIndexOfNode, $targetWorkspaceName);
256256
}
257257

258-
$this->logger->log(sprintf('NodeIndexer (%s): Added / updated node %s.', $documentIdentifier, $contextPath), LOG_DEBUG, null, 'ElasticSearch (CR)');
258+
$this->logger->log(sprintf('NodeIndexer (%s): Indexed node %s.', $documentIdentifier, $contextPath), LOG_DEBUG, null, 'ElasticSearch (CR)');
259259
};
260260

261261
$handleNode = function (NodeInterface $node, \TYPO3\TYPO3CR\Domain\Service\Context $context) use ($targetWorkspaceName, $indexer) {
@@ -265,10 +265,10 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null)
265265
} else {
266266
$documentIdentifier = $this->calculateDocumentIdentifier($node, $targetWorkspaceName);
267267
if ($node->isRemoved()) {
268-
$this->logger->log(sprintf('NodeIndexer (%s): Removing node with identifier %s, no longer in workspace %s', $documentIdentifier, $node->getIdentifier(), $context->getWorkspaceName()), LOG_DEBUG, null, 'ElasticSearch (CR)');
269268
$this->removeNode($node, $context->getWorkspaceName());
269+
$this->logger->log(sprintf('NodeIndexer (%s): Removed node with identifier %s, no longer in workspace %s', $documentIdentifier, $node->getIdentifier(), $context->getWorkspaceName()), LOG_DEBUG, null, 'ElasticSearch (CR)');
270270
} else {
271-
$this->logger->log(sprintf('NodeIndexer (%s): Could not add / update node with identifier %s, not found in workspace %s', $documentIdentifier, $node->getIdentifier(), $context->getWorkspaceName()), LOG_DEBUG, null, 'ElasticSearch (CR)');
271+
$this->logger->log(sprintf('NodeIndexer (%s): Could not index node with identifier %s, not found in workspace %s', $documentIdentifier, $node->getIdentifier(), $context->getWorkspaceName()), LOG_DEBUG, null, 'ElasticSearch (CR)');
272272
}
273273
}
274274
};
@@ -318,7 +318,7 @@ protected function updateFulltext(NodeInterface $node, array $fulltextIndexOfNod
318318
$closestFulltextNode = $closestFulltextNode->getParent();
319319
if ($closestFulltextNode === null) {
320320
// root of hierarchy, no fulltext root found anymore, abort silently...
321-
$this->logger->log('NodeIndexer: No fulltext root found for ' . $node->getPath(), LOG_WARNING);
321+
$this->logger->log(sprintf('NodeIndexer: No fulltext root found for node %s (%)', $node->getPath(), $node->getIdentifier()), LOG_WARNING, null, 'ElasticSearch (CR)');
322322

323323
return;
324324
}
@@ -332,7 +332,7 @@ protected function updateFulltext(NodeInterface $node, array $fulltextIndexOfNod
332332

333333
if ($closestFulltextNode->isRemoved()) {
334334
// fulltext root is removed, abort silently...
335-
$this->logger->log(sprintf('NodeIndexer (%s): Fulltext root found for %s (%s) not updated, it is removed', $closestFulltextNodeDocumentIdentifier, $node->getPath(), $node->getIdentifier()), LOG_DEBUG);
335+
$this->logger->log(sprintf('NodeIndexer (%s): Fulltext root found for %s (%s) not updated, it is removed', $closestFulltextNodeDocumentIdentifier, $node->getPath(), $node->getIdentifier()), LOG_DEBUG, null, 'ElasticSearch (CR)');
336336
return;
337337
}
338338

@@ -393,7 +393,7 @@ protected function updateFulltext(NodeInterface $node, array $fulltextIndexOfNod
393393
]
394394
];
395395

396-
$this->logger->log(sprintf('NodeIndexer (%s): Updated fulltext index for %s (%s)', $closestFulltextNodeDocumentIdentifier, $closestFulltextNodeContextPath, $closestFulltextNode->getIdentifier()), LOG_WARNING);
396+
$this->logger->log(sprintf('NodeIndexer (%s): Updated fulltext index for %s (%s)', $closestFulltextNodeDocumentIdentifier, $closestFulltextNodeContextPath, $closestFulltextNode->getIdentifier()), LOG_WARNING, null, 'ElasticSearch (CR)');
397397
}
398398

399399
/**
@@ -469,7 +469,7 @@ public function flush()
469469
foreach ($bulkRequestTuple as $bulkRequestItem) {
470470
$itemAsJson = json_encode($bulkRequestItem);
471471
if ($itemAsJson === false) {
472-
$this->logger->log('Indexing Error: Bulk request item could not be encoded as JSON - ' . json_last_error_msg(), LOG_ERR, $bulkRequestItem, 'ElasticSearch (CR)');
472+
$this->logger->log('NodeIndexer: Bulk request item could not be encoded as JSON - ' . json_last_error_msg(), LOG_ERR, $bulkRequestItem, 'ElasticSearch (CR)');
473473
continue 2;
474474
}
475475
$tupleAsJson .= $itemAsJson . chr(10);
@@ -482,7 +482,7 @@ public function flush()
482482
foreach (explode(chr(10), $responseAsLines) as $responseLine) {
483483
$response = json_decode($responseLine);
484484
if (!is_object($response) || (isset($response->errors) && $response->errors !== false)) {
485-
$this->logger->log('Indexing Error: ' . $responseLine, LOG_ERR, null, 'ElasticSearch (CR)');
485+
$this->logger->log('NodeIndexer: ' . $responseLine, LOG_ERR, null, 'ElasticSearch (CR)');
486486
}
487487
}
488488
}

0 commit comments

Comments
 (0)