Add optional to add backtrace to log items

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2023-07-06 15:25:33 +02:00
parent a84fa17c73
commit 61167e3149
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB

View file

@ -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);