From 61167e31497ddaa6df18546d3406e45eadf17af5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 6 Jul 2023 15:25:33 +0200 Subject: [PATCH] Add optional to add backtrace to log items Signed-off-by: Robin Appelman --- lib/private/Log.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/private/Log.php b/lib/private/Log.php index 9aff774d0ec..d6750491d92 100644 --- a/lib/private/Log.php +++ b/lib/private/Log.php @@ -221,6 +221,12 @@ class Log implements ILogger, IDataLogger { $this->eventDispatcher->dispatchTyped(new BeforeMessageLoggedEvent($app, $level, $entry)); } + $hasBacktrace = isset($entry['exception']); + $logBacktrace = $this->config->getValue('log.backtrace', false); + if (!$hasBacktrace && $logBacktrace) { + $entry['backtrace'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + } + try { if ($level >= $minLevel) { $this->writeLog($app, $entry, $level);