aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Log.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 9aff774d0ec..eed3d88057a 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -210,6 +210,7 @@ class Log implements ILogger, IDataLogger {
* @return void
*/
public function log(int $level, string $message, array $context = []) {
+ static $inLogEvent = false;
$minLevel = $this->getLogLevel($context);
array_walk($context, [$this->normalizer, 'format']);
@@ -217,8 +218,13 @@ class Log implements ILogger, IDataLogger {
$app = $context['app'] ?? 'no app in context';
$entry = $this->interpolateMessage($context, $message);
- if ($this->eventDispatcher) {
- $this->eventDispatcher->dispatchTyped(new BeforeMessageLoggedEvent($app, $level, $entry));
+ if ($this->eventDispatcher && !$inLogEvent) {
+ $inLogEvent = true;
+ try {
+ $this->eventDispatcher->dispatchTyped(new BeforeMessageLoggedEvent($app, $level, $entry));
+ } catch (Throwable $e) {
+ // ignore exceptions from inside the logger, as trying to log them would lead to recursion
+ }
}
try {