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
Prev Previous commit
Next Next commit
add elastic search specific query logging
  • Loading branch information
LordSimal committed Jan 4, 2024
commit d9e40c277e3066a7ef2b3be84a7f2edc383221dc
2 changes: 2 additions & 0 deletions src/Database/Log/DebugLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function log($level, string|Stringable $message, array $context = []): vo
$this->_totalTime += $context['response']['took'];

$this->_queries[] = [
'isSqlQuery' => false,
'query' => $context['request'],
'took' => $context['response']['took'],
'rows' => $context['response']['hits']['total'],
Expand All @@ -158,6 +159,7 @@ public function log($level, string|Stringable $message, array $context = []): vo
$this->_totalTime += $data['took'];

$this->_queries[] = [
'isSqlQuery' => true,
'query' => (string)$query,
'took' => $data['took'],
'rows' => $data['numRows'],
Expand Down
11 changes: 7 additions & 4 deletions templates/element/sql_log_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@
<?php foreach ($queries as $query) : ?>
<tr>
<td>
<?=
(new SqlFormatter(
<?php
if($query['isSqlQuery']):
Comment thread
LordSimal marked this conversation as resolved.
Outdated
echo (new SqlFormatter(
new HtmlHighlighter([
HtmlHighlighter::HIGHLIGHT_QUOTE => 'style="color: #004d40;"',
HtmlHighlighter::HIGHLIGHT_BACKTICK_QUOTE => 'style="color: #26a69a;"',
Expand All @@ -85,8 +86,10 @@
HtmlHighlighter::HIGHLIGHT_PRE => 'style="color: #222; background-color: transparent;"',
])
))
->format($query['query'])
?>
->format($query['query']);
else:
print_r($query['query']);
endif; ?>
</td>
<td><?= h($query['rows']) ?></td>
<td><?= h($query['took']) ?></td>
Expand Down