diff options
author | Robin Appelman <robin@icewind.nl> | 2023-07-09 02:38:22 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-05-01 18:12:16 +0200 |
commit | d6be80ceaf522b6e6fb419f2037f622b208c5d6c (patch) | |
tree | 30d192bfbce54cbfdc1329b87af43ebea2f07018 /lib/private/DB | |
parent | d82fb01b0a103777e7d999ecc48b8d63cfb7e802 (diff) | |
download | nextcloud-server-d6be80ceaf522b6e6fb419f2037f622b208c5d6c.tar.gz nextcloud-server-d6be80ceaf522b6e6fb419f2037f622b208c5d6c.zip |
feat: add option to add backtrace to the query logger
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/DB')
-rw-r--r-- | lib/private/DB/Connection.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 1340a388571..f704f12d8a8 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -370,6 +370,12 @@ class Connection extends PrimaryReadReplicaConnection { if ($this->systemConfig->getValue('query_log_file_requestid') === 'yes') { $prefix .= Server::get(IRequestId::class)->getId() . "\t"; } + $postfix = ''; + if ($this->systemConfig->getValue('query_log_file_backtrace') === 'yes') { + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + array_pop($trace); + $postfix .= '; ' . json_encode($trace); + } // FIXME: Improve to log the actual target db host $isPrimary = $this->connections['primary'] === $this->_conn; @@ -378,7 +384,7 @@ class Connection extends PrimaryReadReplicaConnection { file_put_contents( $this->systemConfig->getValue('query_log_file', ''), - $prefix . $sql . "\n", + $prefix . $sql . $postfix . "\n", FILE_APPEND ); } |