Skip to content

Commit ebb1349

Browse files
committed
add option to add backtrace to the query logger
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 9bf6911 commit ebb1349

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/private/DB/Connection.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,16 @@ protected function logQueryToFile(string $sql): void {
302302
if ($this->systemConfig->getValue('query_log_file_requestid') === 'yes') {
303303
$prefix .= \OC::$server->get(IRequestId::class)->getId() . "\t";
304304
}
305+
$postfix = '';
306+
if ($this->systemConfig->getValue('query_log_file_backtrace') === 'yes') {
307+
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
308+
array_pop($trace);
309+
$postfix .= '; ' . json_encode($trace);
310+
}
305311

306312
file_put_contents(
307313
$this->systemConfig->getValue('query_log_file', ''),
308-
$prefix . $sql . "\n",
314+
$prefix . $sql . $postfix . "\n",
309315
FILE_APPEND
310316
);
311317
}

0 commit comments

Comments
 (0)