浏览代码

feat: add option to add backtrace to the query logger

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/39247/head
Robin Appelman 10 个月前
父节点
当前提交
d6be80ceaf
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7
    1
      lib/private/DB/Connection.php

+ 7
- 1
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
);
}

正在加载...
取消
保存