Skip to content

Commit 729e03f

Browse files
author
Christoph Lehmann
committed
Simplify logging
* Use static serviceContext as "source". What else should it be? * Get rid of "PHP Warning" and introduce severity with "error" * Remove "context", because every field is context. * Drop the stacktrace, because it too very long (line gets cut off in Loki) * Add additionalData. Our Sentry Client could then pass its EventId with it.
1 parent 9923e05 commit 729e03f

2 files changed

Lines changed: 10 additions & 24 deletions

File tree

Classes/Log/ThrowableStorage/ConsoleStorage.php

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Networkteam\Util\Log\ThrowableStorage;
66

7-
use Neos\Flow\Configuration\ConfigurationManager;
87
use Neos\Flow\Core\Bootstrap;
98
use Neos\Flow\Http\HttpRequestHandlerInterface;
109
use Neos\Flow\Log\Exception\CouldNotOpenResourceException;
@@ -48,30 +47,18 @@ public static function createWithOptions(array $options): ThrowableStorageInterf
4847

4948
public function logThrowable(\Throwable $throwable, array $additionalData = [])
5049
{
51-
if (Bootstrap::$staticObjectManager instanceof ObjectManagerInterface) {
52-
$bootstrap = Bootstrap::$staticObjectManager->get(Bootstrap::class);
53-
/** @var ConfigurationManager $configurationManager */
54-
$configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class);
55-
56-
$serviceContext = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS,
57-
'Networkteam.Util.serviceContext');
58-
} else { // @phpstan-ignore-line
59-
$serviceContext = 'neos-flow';
60-
}
61-
6250
$data = [
6351
'eventTime' => (new \DateTime('now'))->format(DATE_RFC3339),
64-
'serviceContext' => $serviceContext,
65-
'message' => sprintf('PHP Warning: %s', $throwable->getMessage()),
66-
'stackTrace' => $throwable->getTraceAsString(),
67-
'context' => [
68-
'httpRequest' => $this->getHttpRequestContext(),
69-
'reportLocation' => [
70-
'filePath' => $throwable->getFile(),
71-
'lineNumber' => $throwable->getLine(),
72-
'functionName' => self::getFunctionNameForTrace($throwable->getTrace()),
73-
],
74-
]
52+
'severity' => 'error',
53+
'message' => $throwable->getMessage(),
54+
'errorLocation' => [
55+
'filePath' => $throwable->getFile(),
56+
'lineNumber' => $throwable->getLine(),
57+
'functionName' => self::getFunctionNameForTrace($throwable->getTrace()),
58+
],
59+
'httpRequest' => $this->getHttpRequestContext(),
60+
'additionalData' => $additionalData,
61+
'source' => 'neos-flow'
7562
];
7663

7764
$output = json_encode($data);

Configuration/Settings.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
Networkteam:
22
Util:
3-
serviceContext: 'neos-flow'
43
OpenExchangeRateConverter:
54
appId: 'b05f50cd27864a519887e3141c64cb34'
65
baseUrl: 'http://openexchangerates.org/api/'

0 commit comments

Comments
 (0)