Skip to content

Commit

Permalink
apply changes from Christopher-HM
Browse files Browse the repository at this point in the history
  • Loading branch information
LordSimal committed Jan 4, 2024
1 parent 77b6026 commit b96c1fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/Database/Log/DebugLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ public function log($level, string|Stringable $message, array $context = []): vo
$this->_totalTime += $context['response']['took'];

Check warning on line 138 in src/Database/Log/DebugLog.php

View check run for this annotation

Codecov / codecov/patch

src/Database/Log/DebugLog.php#L138

Added line #L138 was not covered by tests

$this->_queries[] = [
'isSqlQuery' => false,
'query' => $context['request'],
'took' => $context['response']['took'],
'rows' => $context['response']['hits']['total'],
'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,
];

Check warning on line 148 in src/Database/Log/DebugLog.php

View check run for this annotation

Codecov / codecov/patch

src/Database/Log/DebugLog.php#L140-L148

Added lines #L140 - L148 were not covered by tests

return;

Check warning on line 150 in src/Database/Log/DebugLog.php

View check run for this annotation

Codecov / codecov/patch

src/Database/Log/DebugLog.php#L150

Added line #L150 was not covered by tests
Expand All @@ -159,7 +162,6 @@ 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
8 changes: 2 additions & 6 deletions templates/element/sql_log_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
<?php foreach ($queries as $query) : ?>
<tr>
<td>
<?php
if ($query['isSqlQuery']):
<?= ($query['isSqlQuery']):
echo (new SqlFormatter(
new HtmlHighlighter([
HtmlHighlighter::HIGHLIGHT_QUOTE => 'style="color: #004d40;"',
Expand All @@ -86,10 +85,7 @@
HtmlHighlighter::HIGHLIGHT_PRE => 'style="color: #222; background-color: transparent;"',
])
))
->format($query['query']);
else:
print_r($query['query']);
endif; ?>
->format($query['query']) ?>
</td>
<td><?= h($query['rows']) ?></td>
<td><?= h($query['took']) ?></td>
Expand Down

0 comments on commit b96c1fd

Please sign in to comment.