aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Log.php
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-01-03 19:03:57 +0100
committerJulius Härtl <jus@bitgrid.net>2023-01-16 09:47:31 +0100
commit00b7575c89815aa218e7e3ed3d61b25ee65f244f (patch)
tree002f0cc4ee86cb2c79eb8c8c089cbcba6c9511ac /lib/private/Log.php
parent5e090d044d3d660316450c3d4d2d7bfc3bde20dd (diff)
downloadnextcloud-server-00b7575c89815aa218e7e3ed3d61b25ee65f244f.tar.gz
nextcloud-server-00b7575c89815aa218e7e3ed3d61b25ee65f244f.zip
perf(logging): Return early when log level does not match before serializing an exception
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/Log.php')
-rw-r--r--lib/private/Log.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 4ab647bc6c1..e4be5134f11 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -312,6 +312,11 @@ class Log implements ILogger, IDataLogger {
$app = $context['app'] ?? 'no app in context';
$level = $context['level'] ?? ILogger::ERROR;
+ $minLevel = $this->getLogLevel($context);
+ if ($level < $minLevel && ($this->crashReporters === null || !$this->crashReporters->hasReporters())) {
+ return;
+ }
+
// if an error is raised before the autoloader is properly setup, we can't serialize exceptions
try {
$serializer = $this->getSerializer();
@@ -325,7 +330,6 @@ class Log implements ILogger, IDataLogger {
$data = array_merge($serializer->serializeException($exception), $data);
$data = $this->interpolateMessage($data, $context['message'] ?? '--', 'CustomMessage');
- $minLevel = $this->getLogLevel($context);
array_walk($context, [$this->normalizer, 'format']);