chore(src): log_write 函数支持设置调用栈深度

This commit is contained in:
2025-12-10 10:17:54 +08:00
parent 1366d974cf
commit fd7593c72b

View File

@@ -2135,12 +2135,13 @@ function exportForLog($data): string
* @param string $msg 日志内容
* @param string $level 日志级别 debug、info、warning、error
* @param string $file 日志文件名(不含路径)
* @param int $callerDep 调用栈深度默认1当前函数调用
*/
function log_write(string $message, string $level = 'info', string $filename = ''): void
function log_write(string $message, string $level = 'info', string $filename = '', int $callerDep = 1): void
{
// 日志文件最大大小(字节)
$maxFileSize = 10485760; // 10MB
$callerInfo = CallerInfo::getCallerInfo(1);
$callerInfo = CallerInfo::getCallerInfo($callerDep);
// 格式化日志内容
$content = sprintf(