Skip to content

Commit bd7069c

Browse files
Merge pull request #348 from DrillSergeant/feature/add-indexname-to-logs
Add indexname to log entries
2 parents 8c6fb91 + cb11c7b commit bd7069c

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Classes/Eel/ElasticSearchQueryBuilder.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient;
1919
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception;
2020
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception\QueryBuildingException;
21+
use Flowpack\ElasticSearch\Domain\Model\Index;
2122
use Flowpack\ElasticSearch\Domain\Model\Mapping;
2223
use Neos\Flow\Log\ThrowableStorageInterface;
2324
use Neos\Flow\Log\Utility\LogEnvironment;
@@ -590,7 +591,7 @@ public function fetch(): array
590591

591592
$this->result['nodes'] = [];
592593

593-
$this->logThisQuery && $this->logger->debug(sprintf('Query Log (%s): %s -- execution time: %s ms -- Limit: %s -- Number of results returned: %s -- Total Results: %s', $this->logMessage, $request, (($timeAfterwards - $timeBefore) * 1000), $this->limit, count($searchResult->getHits()), $searchResult->getTotal()), LogEnvironment::fromMethodName(__METHOD__));
594+
$this->logThisQuery && $this->logger->debug(sprintf('Query Log (%s): Indexname: %s %s -- execution time: %s ms -- Limit: %s -- Number of results returned: %s -- Total Results: %s', $this->logMessage, $this->getIndexName(), $request, (($timeAfterwards - $timeBefore) * 1000), $this->limit, count($searchResult->getHits()), $searchResult->getTotal()), LogEnvironment::fromMethodName(__METHOD__));
594595

595596
if (count($searchResult->getHits()) > 0) {
596597
$this->result['nodes'] = $this->convertHitsToNodes($searchResult->getHits());
@@ -661,7 +662,7 @@ public function count(): int
661662
$treatedContent = $response->getTreatedContent();
662663
$count = (int)$treatedContent['count'];
663664

664-
$this->logThisQuery && $this->logger->debug('Count Query Log (' . $this->logMessage . '): ' . $request . ' -- execution time: ' . (($timeAfterwards - $timeBefore) * 1000) . ' ms -- Total Results: ' . $count, LogEnvironment::fromMethodName(__METHOD__));
665+
$this->logThisQuery && $this->logger->debug('Count Query Log (' . $this->logMessage . '): ' . 'Indexname: ' . $this->getIndexName() . ' ' . $request . ' -- execution time: ' . (($timeAfterwards - $timeBefore) * 1000) . ' ms -- Total Results: ' . $count, LogEnvironment::fromMethodName(__METHOD__));
665666

666667
return $count;
667668
}
@@ -1006,4 +1007,14 @@ protected function convertValue($value)
10061007

10071008
return $value;
10081009
}
1010+
1011+
/**
1012+
* Retrieve the indexname
1013+
*
1014+
* @return string
1015+
*/
1016+
public function getIndexName(): string
1017+
{
1018+
return $this->elasticSearchClient->getIndexName();
1019+
}
10091020
}

0 commit comments

Comments
 (0)