FOSElasticaBundle/Client.php

33 lines
678 B
PHP
Raw Normal View History

2011-10-04 17:01:38 +02:00
<?php
2011-10-04 17:26:14 +02:00
2011-10-04 17:01:38 +02:00
namespace FOQ\ElasticaBundle;
use Elastica_Client;
2011-10-04 17:53:28 +02:00
use FOQ\ElasticaBundle\Logger\ElasticaLogger;
2011-10-04 17:01:38 +02:00
/**
* @author Gordon Franke <info@nevalon.de>
*/
class Client extends Elastica_Client
{
2011-10-04 17:26:14 +02:00
protected $logger;
2011-10-04 17:53:28 +02:00
public function setLogger(ElasticaLogger $logger)
2011-10-04 17:01:38 +02:00
{
$this->logger = $logger;
}
2011-10-04 17:26:14 +02:00
public function request($path, $method, $data = array())
{
$start = microtime(true);
$response = parent::request($path, $method, $data);
2011-10-04 17:26:14 +02:00
if (null !== $this->logger) {
$time = microtime(true) - $start;
$this->logger->logQuery($path, $method, $data, $time);
2011-10-04 17:26:14 +02:00
}
2011-10-04 17:01:38 +02:00
return $response;
2011-10-04 17:01:38 +02:00
}
}