Skip to content

Commit 519e4fd

Browse files
committed
add elastic search specific query logging
1 parent fd6a99d commit 519e4fd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Database/Log/DebugLog.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,25 @@ public function totalTime(): float
127127
*/
128128
public function log($level, string|Stringable $message, array $context = []): void
129129
{
130-
$query = $context['query'];
130+
$query = $context['query'] ?? null;
131131

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

136+
// This specific to Elastic Search
137+
if (isset($context['request']) && isset($context['response'])) {
138+
$this->_totalTime += $context['response']['took'];
139+
140+
$this->_queries[] = [
141+
'query' => $context['request'],
142+
'took' => $context['response']['took'],
143+
'rows' => $context['response']['hits']['total'],
144+
];
145+
146+
return;
147+
}
148+
136149
if (
137150
!$query instanceof LoggedQuery ||
138151
($this->_includeSchema === false && $this->isSchemaQuery($query))

0 commit comments

Comments
 (0)