Skip to content

Commit 860b504

Browse files
committed
Improve log integration for elasticearch
Not all queries have 'took'. Account for that and use defaults values. Fixes #989
1 parent cdb3138 commit 860b504

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/Database/Log/DebugLog.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,16 @@ public function log($level, string|Stringable $message, array $context = []): vo
135135

136136
// This specific to Elastic Search
137137
if (!$query instanceof LoggedQuery && isset($context['request']) && isset($context['response'])) {
138-
$this->_totalTime += $context['response']['took'];
138+
$took = $context['response']['took'] ?? 0;
139+
$this->_totalTime += $took;
139140

140141
$this->_queries[] = [
141142
'query' => json_encode([
142143
'method' => $context['request']['method'],
143144
'path' => $context['request']['path'],
144145
'data' => $context['request']['data'],
145146
], JSON_PRETTY_PRINT),
146-
'took' => $context['response']['took'] ?: 0,
147+
'took' => $took ?: 0,
147148
'rows' => $context['response']['hits']['total']['value'] ?? $context['response']['hits']['total'] ?? 0,
148149
];
149150

0 commit comments

Comments
 (0)