Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/Database/Log/DebugLog.php">
<InternalMethod>
<code><![CDATA[getContext]]></code>
<code><![CDATA[jsonSerialize]]></code>
</InternalMethod>
</file>
Expand Down
5 changes: 5 additions & 0 deletions src/Database/Log/DebugLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public function totalTime(): float
*/
public function log($level, string|Stringable $message, array $context = []): void
{
/** @var \Cake\Database\Log\LoggedQuery|object|null $query */
$query = $context['query'] ?? null;

if ($this->_logger) {
Expand All @@ -153,6 +154,9 @@ public function log($level, string|Stringable $message, array $context = []): vo
], JSON_PRETTY_PRINT),
'took' => $took,
'rows' => $context['response']['hits']['total']['value'] ?? $context['response']['hits']['total'] ?? 0,
'inTransaction' => $this->inTransaction,
'isCommitOrRollback' => false,
'role' => '',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added to make it consistent for Elastic Search query logging as well

];

return;
Expand Down Expand Up @@ -183,6 +187,7 @@ public function log($level, string|Stringable $message, array $context = []): vo
'rows' => $data['numRows'],
'inTransaction' => $this->inTransaction,
'isCommitOrRollback' => $isCommitOrRollback,
'role' => $query->getContext()['role'],
];

if ($isCommitOrRollback) {
Expand Down
2 changes: 2 additions & 0 deletions templates/element/sql_log_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<th>Query</th>
<th>Rows</th>
<th>Took (ms)</th>
<th>Role</th>
</tr>
</thead>
<tbody>
Expand All @@ -90,6 +91,7 @@
</td>
<td><?= h($query['rows']) ?></td>
<td><?= h($query['took']) ?></td>
<td><?= h($query['role']) ?></td>
</tr>
<?php if ($query['isCommitOrRollback']): ?>
<tr>
Expand Down
Loading