mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Allow to prefix the Query log with the request id
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
07a9f34385
commit
1c138d3ae2
1 changed files with 8 additions and 2 deletions
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue