mirror of
https://github.com/nextcloud/server.git
synced 2024-09-02 05:55:17 +02:00
perf(logging): Return early when log level does not match before serializing an exception
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
5e090d044d
commit
00b7575c89
@ -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']);
|
||||
|
||||
|
@ -147,4 +147,8 @@ class Registry implements IRegistry {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hasReporters(): bool {
|
||||
return !empty($this->lazyReporters) || !empty($this->reporters);
|
||||
}
|
||||
}
|
||||
|
@ -81,4 +81,13 @@ interface IRegistry {
|
||||
* @since 17.0.0
|
||||
*/
|
||||
public function delegateMessage(string $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Check if any reporter has been registered to delegate to
|
||||
*
|
||||
* @return bool
|
||||
* @deprecated use internally only
|
||||
* @since 26.0.0
|
||||
*/
|
||||
public function hasReporters(): bool;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user