Commit b088b928 authored by crell's avatar crell Committed by Christian Kuhn
Browse files

[BUGFIX] Allow logging and formatting of all Throwables

Resolves: #94382
Related: #94315
Releases: master
Change-Id: I250ccfa09863f7cdc48ad58bb7d9d5fc922d76c5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69523


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 94a56bc3
......@@ -79,11 +79,8 @@ abstract class AbstractWriter implements WriterInterface
*
* The format here is nearly the same as just casting an exception to a string,
* but omits the full class namespace and stack trace, as those get very long.
*
* @param \Exception $ex
* @return string
*/
protected function formatException(\Exception $ex): string
protected function formatException(\Throwable $ex): string
{
$classname = get_class($ex);
if ($pos = strrpos($classname, '\\')) {
......
......@@ -66,7 +66,7 @@ class DatabaseWriter extends AbstractWriter
$context = $record->getData();
if (!empty($context)) {
// Fold an exception into the message, and string-ify it into context so it can be jsonified.
if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
if (isset($context['exception']) && $context['exception'] instanceof \Throwable) {
$context['exception'] = (string)$context['exception'];
}
$data = '- ' . json_encode($context);
......
......@@ -137,7 +137,7 @@ class FileWriter extends AbstractWriter
$message = $record->getMessage();
if (!empty($context)) {
// Fold an exception into the message, and string-ify it into context so it can be jsonified.
if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
if (isset($context['exception']) && $context['exception'] instanceof \Throwable) {
$message .= $this->formatException($context['exception']);
$context['exception'] = (string)$context['exception'];
}
......@@ -150,7 +150,7 @@ class FileWriter extends AbstractWriter
strtoupper($record->getLevel()),
$record->getRequestId(),
$record->getComponent(),
$this->interpolate($record->getMessage(), $context),
$this->interpolate($message, $context),
$data
);
......
......@@ -36,7 +36,7 @@ class PhpErrorLogWriter extends AbstractWriter
$message = $record->getMessage();
if (!empty($context)) {
// Fold an exception into the message, and string-ify it into context so it can be jsonified.
if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
if (isset($context['exception']) && $context['exception'] instanceof \Throwable) {
$message .= $this->formatException($context['exception']);
$context['exception'] = (string)$context['exception'];
}
......
......@@ -110,7 +110,7 @@ class SyslogWriter extends AbstractWriter
$message = $record->getMessage();
if (!empty($context)) {
// Fold an exception into the message, and string-ify it into context so it can be jsonified.
if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
if (isset($context['exception']) && $context['exception'] instanceof \Throwable) {
$message .= $this->formatException($context['exception']);
$context['exception'] = (string)$context['exception'];
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment