mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 06:23:18 +00:00
Configure elasticsearch logger in dev environment
This commit is contained in:
@@ -20,6 +20,9 @@ use Alchemy\Phrasea\Exception\RuntimeException;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Alchemy\Phrasea\Model\Entities\FeedEntry;
|
use Alchemy\Phrasea\Model\Entities\FeedEntry;
|
||||||
use Elasticsearch\Client;
|
use Elasticsearch\Client;
|
||||||
|
use Monolog\Handler\RotatingFileHandler;
|
||||||
|
use Psr\Log\LogLevel;
|
||||||
|
use Symfony\Bridge\Monolog\Logger;
|
||||||
|
|
||||||
class ElasticSearchEngine implements SearchEngineInterface
|
class ElasticSearchEngine implements SearchEngineInterface
|
||||||
{
|
{
|
||||||
@@ -355,7 +358,18 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
'index' => 'phraseanet',
|
'index' => 'phraseanet',
|
||||||
], $options);
|
], $options);
|
||||||
|
|
||||||
$client = new Client(['hosts' => [sprintf('%s:%s', $options['host'], $options['port'])]]);
|
$clientParams = ['hosts' => [sprintf('%s:%s', $options['host'], $options['port'])]];
|
||||||
|
|
||||||
|
if ($app['debug']) {
|
||||||
|
/** @var $logger Logger */
|
||||||
|
$logger = new $app['monolog.logger.class']('search logger');
|
||||||
|
$logger->pushHandler(new RotatingFileHandler($app['log.path'].DIRECTORY_SEPARATOR.'elasticsearch.log', 2), Logger::INFO);
|
||||||
|
|
||||||
|
$clientParams['logObject'] = $logger;
|
||||||
|
$clientParams['logging'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$client = new Client($clientParams);
|
||||||
|
|
||||||
return new static($app, $client, $app['serializer.es-record'], $options['index']);
|
return new static($app, $client, $app['serializer.es-record'], $options['index']);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user