Skip to content

Commit c816496

Browse files
committed
TASK: Add log environment data to all logger calls
1 parent e890ed8 commit c816496

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Classes/Indexer/NodeIndexer.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use Neos\ContentRepository\Search\Indexer\AbstractNodeIndexer;
3535
use Neos\ContentRepository\Search\Indexer\BulkNodeIndexerInterface;
3636
use Neos\Flow\Annotations as Flow;
37+
use Neos\Flow\Log\Utility\LogEnvironment;
3738
use Neos\Flow\Persistence\Exception\IllegalObjectTypeException;
3839
use Psr\Log\LoggerInterface;
3940

@@ -163,6 +164,7 @@ public function setIndexNamePostfix(string $indexNamePostfix): void
163164
*
164165
* @return Index
165166
* @throws Exception
167+
* @throws \Flowpack\ElasticSearch\Exception
166168
*/
167169
public function getIndex(): Index
168170
{
@@ -208,13 +210,13 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null)
208210

209211
if ($this->bulkProcessing === false) {
210212
// Remove document with the same contextPathHash but different NodeType, required after NodeType change
211-
$this->logger->debug(sprintf('NodeIndexer (%s): Search and remove duplicate document for node %s (%s) if needed.', $documentIdentifier, $contextPath, $node->getIdentifier()));
213+
$this->logger->debug(sprintf('NodeIndexer (%s): Search and remove duplicate document for node %s (%s) if needed.', $documentIdentifier, $contextPath, $node->getIdentifier()), LogEnvironment::fromMethodName(__METHOD__));
212214
$this->documentDriver->deleteDuplicateDocumentNotMatchingType($this->getIndex(), $documentIdentifier, $node->getNodeType());
213215
}
214216

215217
$fulltextIndexOfNode = [];
216218
$nodePropertiesToBeStoredInIndex = $this->extractPropertiesAndFulltext($node, $fulltextIndexOfNode, function ($propertyName) use ($documentIdentifier, $node) {
217-
$this->logger->debug(sprintf('NodeIndexer (%s) - Property "%s" not indexed because no configuration found, node type %s.', $documentIdentifier, $propertyName, $node->getNodeType()->getName()));
219+
$this->logger->debug(sprintf('NodeIndexer (%s) - Property "%s" not indexed because no configuration found, node type %s.', $documentIdentifier, $propertyName, $node->getNodeType()->getName()), LogEnvironment::fromMethodName(__METHOD__));
218220
});
219221

220222
$document = new ElasticSearchDocument($mappingType,
@@ -249,9 +251,9 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null)
249251
$documentIdentifier = $this->calculateDocumentIdentifier($node, $targetWorkspaceName);
250252
if ($node->isRemoved()) {
251253
$this->removeNode($node, $context->getWorkspaceName());
252-
$this->logger->debug(sprintf('NodeIndexer (%s): Removed node with identifier %s, no longer in workspace %s', $documentIdentifier, $node->getIdentifier(), $context->getWorkspaceName()));
254+
$this->logger->debug(sprintf('NodeIndexer (%s): Removed node with identifier %s, no longer in workspace %s', $documentIdentifier, $node->getIdentifier(), $context->getWorkspaceName()), LogEnvironment::fromMethodName(__METHOD__));
253255
} else {
254-
$this->logger->debug(sprintf('NodeIndexer (%s): Could not index node with identifier %s, not found in workspace %s with dimensions %s', $documentIdentifier, $node->getIdentifier(), $context->getWorkspaceName(), json_encode($context->getDimensions())));
256+
$this->logger->debug(sprintf('NodeIndexer (%s): Could not index node with identifier %s, not found in workspace %s with dimensions %s', $documentIdentifier, $node->getIdentifier(), $context->getWorkspaceName(), json_encode($context->getDimensions())), LogEnvironment::fromMethodName(__METHOD__));
255257
}
256258
}
257259
};
@@ -316,14 +318,15 @@ public function removeNode(NodeInterface $node, string $targetWorkspaceName = nu
316318
$this->currentBulkRequest[] = $this->documentDriver->delete($node, $documentIdentifier);
317319
$this->currentBulkRequest[] = $this->indexerDriver->fulltext($node, [], $targetWorkspaceName);
318320

319-
$this->logger->debug(sprintf('NodeIndexer (%s): Removed node %s (%s) from index.', $documentIdentifier, $node->getContextPath(), $node->getIdentifier()));
321+
$this->logger->debug(sprintf('NodeIndexer (%s): Removed node %s (%s) from index.', $documentIdentifier, $node->getContextPath(), $node->getIdentifier()), LogEnvironment::fromMethodName(__METHOD__));
320322
}
321323

322324
/**
323325
* Perform the current bulk request
324326
*
325327
* @return void
326328
* @throws Exception
329+
* @throws \Flowpack\ElasticSearch\Exception
327330
*/
328331
public function flush()
329332
{
@@ -368,6 +371,7 @@ public function flush()
368371
* @return void
369372
* @throws Exception
370373
* @throws ApiException
374+
* @throws \Flowpack\ElasticSearch\Exception
371375
*/
372376
public function updateIndexAlias(): void
373377
{

0 commit comments

Comments
 (0)