diff options
author | Marcel Müller <marcel-mueller@gmx.de> | 2025-04-19 21:24:50 +0200 |
---|---|---|
committer | Marcel Müller <marcel-mueller@gmx.de> | 2025-04-19 21:29:26 +0200 |
commit | 0955b0a39dfbea341e4b7942c006f4397cc850e7 (patch) | |
tree | 90b699ca72477c77d04cc44730c3a82923408340 | |
parent | 9cd42d67fbe733cb65cb0cef93373f8f0b3a9c0a (diff) | |
download | nextcloud-server-0955b0a39dfbea341e4b7942c006f4397cc850e7.tar.gz nextcloud-server-0955b0a39dfbea341e4b7942c006f4397cc850e7.zip |
feat: Add option to also log parameters to query log
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
-rw-r--r-- | lib/private/DB/Connection.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index eecf83ace95..96dd578b2ef 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -414,7 +414,7 @@ class Connection extends PrimaryReadReplicaConnection { $sql = $this->finishQuery($sql); $this->queriesExecuted++; - $this->logQueryToFile($sql); + $this->logQueryToFile($sql, $params); try { return parent::executeQuery($sql, $params, $types, $qcp); } catch (\Exception $e) { @@ -461,7 +461,7 @@ class Connection extends PrimaryReadReplicaConnection { } $sql = $this->finishQuery($sql); $this->queriesExecuted++; - $this->logQueryToFile($sql); + $this->logQueryToFile($sql, $params); try { return (int)parent::executeStatement($sql, $params, $types); } catch (\Exception $e) { @@ -470,14 +470,19 @@ class Connection extends PrimaryReadReplicaConnection { } } - protected function logQueryToFile(string $sql): void { + protected function logQueryToFile(string $sql, array $params): void { $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 .= Server::get(IRequestId::class)->getId() . "\t"; } + $postfix = ''; + if ($this->systemConfig->getValue('query_log_file_parameters') === 'yes') { + $postfix .= '; ' . json_encode($params); + } + if ($this->systemConfig->getValue('query_log_file_backtrace') === 'yes') { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); array_pop($trace); |