diff --git a/Client.php b/Client.php index ea0c572..7719095 100644 --- a/Client.php +++ b/Client.php @@ -27,7 +27,7 @@ class Client extends ElasticaClient 'transport' => $connection->getTransport(), ); - $this->_logger->logQuery($path, $method, $data, $time, $connection_array); + $this->_logger->logQuery($path, $method, $data, $time, $connection_array, $query); } return $response; diff --git a/Logger/ElasticaLogger.php b/Logger/ElasticaLogger.php index 7aacac5..60f28db 100644 --- a/Logger/ElasticaLogger.php +++ b/Logger/ElasticaLogger.php @@ -37,10 +37,11 @@ class ElasticaLogger implements LoggerInterface * @param string $path Path to call * @param string $method Rest method to use (GET, POST, DELETE, PUT) * @param array $data arguments + * @param array $query arguments * @param float $time execution time * @param array $connection host, port and transport of the query */ - public function logQuery($path, $method, $data, $time, $connection = array()) + public function logQuery($path, $method, $data, $time, $connection = array(), $query = array()) { if ($this->debug) { $this->queries[] = array( @@ -48,7 +49,8 @@ class ElasticaLogger implements LoggerInterface 'method' => $method, 'data' => $data, 'executionMS' => $time, - 'connection' => $connection + 'connection' => $connection, + 'queryString' => $query, ); } diff --git a/Resources/views/Collector/elastica.html.twig b/Resources/views/Collector/elastica.html.twig index 0eb50a6..637dae7 100644 --- a/Resources/views/Collector/elastica.html.twig +++ b/Resources/views/Collector/elastica.html.twig @@ -44,6 +44,7 @@ {% for key, query in collector.queries %}
{{ query.data|json_encode }}
@@ -60,7 +61,7 @@
{% endif %}
diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php
index c8509cf..8a9d91a 100644
--- a/Tests/ClientTest.php
+++ b/Tests/ClientTest.php
@@ -24,6 +24,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
Request::GET,
$this->isType('array'),
$this->isType('float'),
+ $this->isType('array'),
$this->isType('array')
);
diff --git a/Tests/Logger/ElasticaLoggerTest.php b/Tests/Logger/ElasticaLoggerTest.php
index 30ce30c..96adf53 100644
--- a/Tests/Logger/ElasticaLoggerTest.php
+++ b/Tests/Logger/ElasticaLoggerTest.php
@@ -70,6 +70,7 @@ class ElasticaLoggerTest extends \PHPUnit_Framework_TestCase
$data = array('data');
$time = 12;
$connection = array('host' => 'localhost', 'port' => '8999', 'transport' => 'https');
+ $query = array('search_type' => 'dfs_query_then_fetch');
$expected = array(
'path' => $path,
@@ -77,9 +78,10 @@ class ElasticaLoggerTest extends \PHPUnit_Framework_TestCase
'data' => $data,
'executionMS' => $time,
'connection' => $connection,
+ 'queryString' => $query,
);
- $elasticaLogger->logQuery($path, $method, $data, $time, $connection);
+ $elasticaLogger->logQuery($path, $method, $data, $time, $connection, $query);
$returnedQueries = $elasticaLogger->getQueries();
$this->assertEquals($expected, $returnedQueries[0]);
}