diff options
author | Joas Schilling <coding@schilljs.com> | 2022-02-16 23:43:36 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-02-23 11:01:58 +0100 |
commit | 1c138d3ae28287a5a5854ef5142ee66ae88f801c (patch) | |
tree | 5cbe2a87cf691cc9b79312964ae7c07dd749ad3c | |
parent | 07a9f34385a80570c2121f73d04bba12cfd39b3d (diff) | |
download | nextcloud-server-1c138d3ae28287a5a5854ef5142ee66ae88f801c.tar.gz nextcloud-server-1c138d3ae28287a5a5854ef5142ee66ae88f801c.zip |
Allow to prefix the Query log with the request id
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/private/DB/Connection.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index b8d1a747fa2..5368ae9100c 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 { @@ -271,11 +272,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 ); } |