aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/Connection.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/DB/Connection.php')
-rw-r--r--lib/private/DB/Connection.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index e32c530c19e..6f89ba64e80 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -53,6 +53,7 @@ use OC\DB\QueryBuilder\QueryBuilder;
use OC\SystemConfig;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\ILogger;
+use OCP\IRequestId;
use OCP\PreConditionNotMetException;
class Connection extends \Doctrine\DBAL\Connection {
@@ -281,11 +282,16 @@ class Connection extends \Doctrine\DBAL\Connection {
}
protected function logQueryToFile(string $sql): void {
- $logFile = $this->systemConfig->getValue('query_log_file', '');
+ $logFile = $this->systemConfig->getValue('query_log_file');
if ($logFile !== '' && is_writable(dirname($logFile)) && (!file_exists($logFile) || is_writable($logFile))) {
+ $prefix = '';
+ if ($this->systemConfig->getValue('query_log_file_requestid') === 'yes') {
+ $prefix .= \OC::$server->get(IRequestId::class)->getId() . "\t";
+ }
+
file_put_contents(
$this->systemConfig->getValue('query_log_file', ''),
- $sql . "\n",
+ $prefix . $sql . "\n",
FILE_APPEND
);
}