Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"require-dev": {
"cakephp/authorization": "^3.0",
"cakephp/cakephp-codesniffer": "^5.0",
"phpunit/phpunit": "^10.1.0"
"phpunit/phpunit": "^10.1.0 <=10.5.3"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
"autoload": {
"psr-4": {
Expand Down
7 changes: 6 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.10.0@a5effd2d2dddd1a7ea7a0f6a051ce63ff979e356">
<files psalm-version="5.13.1@086b94371304750d1c673315321a55d15fc59015">
<file src="src/Database/Log/DebugLog.php">
<InternalMethod>
<code>jsonSerialize</code>
</InternalMethod>
</file>
<file src="src/DebugInclude.php">
<PossiblyNullArrayOffset>
<code><![CDATA[$this->_composerPaths]]></code>
Expand Down
24 changes: 22 additions & 2 deletions src/Database/Log/DebugLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,33 @@ public function totalTime(): float
*/
public function log($level, string|Stringable $message, array $context = []): void
{
$query = $context['query'];
$query = $context['query'] ?? null;

if ($this->_logger) {
$this->_logger->log($level, $message, $context);
}

if ($this->_includeSchema === false && $this->isSchemaQuery($query)) {
// This specific to Elastic Search
if (!$query instanceof LoggedQuery && isset($context['request']) && isset($context['response'])) {
$this->_totalTime += $context['response']['took'];

$this->_queries[] = [
'query' => json_encode([
'method' => $context['request']['method'],
'path' => $context['request']['path'],
'data' => $context['request']['data'],
], JSON_PRETTY_PRINT),
'took' => $context['response']['took'] ?: 0,
'rows' => $context['response']['hits']['total']['value'] ?? $context['response']['hits']['total'] ?? 0,
];

return;
}

if (
!$query instanceof LoggedQuery ||
($this->_includeSchema === false && $this->isSchemaQuery($query))
) {
return;
}

Expand Down
10 changes: 9 additions & 1 deletion src/Panel/SqlLogPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace DebugKit\Panel;

use Cake\Core\Configure;
use Cake\Database\Driver;
use Cake\Datasource\ConnectionInterface;
use Cake\Datasource\ConnectionManager;
use Cake\ORM\Locator\LocatorAwareTrait;
Expand Down Expand Up @@ -57,7 +58,14 @@ public function initialize(): void
) {
continue;
}
$logger = $connection->getDriver()->getLogger();
$driver = $connection->getDriver();
$logger = null;
if ($driver instanceof Driver) {
$logger = $driver->getLogger();
} elseif (method_exists($connection, 'getLogger')) {
// ElasticSearch connection holds the logger, not the Elastica Driver
$logger = $connection->getLogger();
}

if ($logger instanceof DebugLog) {
$logger->setIncludeSchema($includeSchemaReflection);
Expand Down