aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-09-19 18:33:45 +0200
committerGitHub <noreply@github.com>2019-09-19 18:33:45 +0200
commitb2aec1d81691ce054a5eb4742f18b2fd62d9cb33 (patch)
tree8e2ec92ec30cd1f724d6d6c652ed952df7e66561 /lib
parentf750193920e7c9086233ea09d792f18083208583 (diff)
parent2943c18548e2dbd19b76b26b95d9b4031126c824 (diff)
downloadnextcloud-server-b2aec1d81691ce054a5eb4742f18b2fd62d9cb33.tar.gz
nextcloud-server-b2aec1d81691ce054a5eb4742f18b2fd62d9cb33.zip
Merge pull request #17206 from nextcloud/logger-catch-exceptions
catch exceptions that occur during logging
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Log.php55
1 files changed, 31 insertions, 24 deletions
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 4af833d778f..04148d549d6 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -214,24 +214,27 @@ class Log implements ILogger {
}
$message = strtr($message, $replace);
- if ($level >= $minLevel) {
- $this->writeLog($app, $message, $level);
-
- if ($this->crashReporters !== null) {
- $messageContext = array_merge(
- $context,
- [
- 'level' => $level
- ]
- );
- $this->crashReporters->delegateMessage($message, $messageContext);
- }
- } else {
- if ($this->crashReporters !== null) {
- $this->crashReporters->delegateBreadcrumb($message, 'log', $context);
+ try {
+ if ($level >= $minLevel) {
+ $this->writeLog($app, $message, $level);
+
+ if ($this->crashReporters !== null) {
+ $messageContext = array_merge(
+ $context,
+ [
+ 'level' => $level
+ ]
+ );
+ $this->crashReporters->delegateMessage($message, $messageContext);
+ }
+ } else {
+ if ($this->crashReporters !== null) {
+ $this->crashReporters->delegateBreadcrumb($message, 'log', $context);
+ }
}
+ } catch (\Throwable $e) {
+ // make sure we dont hard crash if logging fails
}
-
}
private function getLogLevel($context) {
@@ -318,16 +321,20 @@ class Log implements ILogger {
array_walk($context, [$this->normalizer, 'format']);
- if ($level >= $minLevel) {
- if (!$this->logger instanceof IFileBased) {
- $data = json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR);
+ try {
+ if ($level >= $minLevel) {
+ if (!$this->logger instanceof IFileBased) {
+ $data = json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR);
+ }
+ $this->writeLog($app, $data, $level);
}
- $this->writeLog($app, $data, $level);
- }
- $context['level'] = $level;
- if (!is_null($this->crashReporters)) {
- $this->crashReporters->delegateReport($exception, $context);
+ $context['level'] = $level;
+ if (!is_null($this->crashReporters)) {
+ $this->crashReporters->delegateReport($exception, $context);
+ }
+ } catch (\Throwable $e) {
+ // make sure we dont hard crash if logging fails
}
}