Skip to content

Commit

Permalink
Check for sapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Lehmann committed Feb 12, 2024
1 parent 8bdd2bf commit a777eef
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions Classes/Writer/JsonWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,13 @@ public function writeLog(LogRecord $record)
'context' => $context
];

$method = $_SERVER['REQUEST_METHOD'] ?? null;
if ($method) {
$data['url'] = $this->anonymizeToken(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
$data['method'] = $method;
$requestId = $_SERVER['X-REQUEST-ID'] ?? $_SERVER['HTTP_X_REQUEST_ID'] ?? null;
if ($requestId) {
$data['request_id'] = $requestId;
}
} else {
if (PHP_SAPI === 'cli') {
global $argv;
$data['command_line'] = implode(' ', $argv);
}

if ($this->options !== []) {
$data['logger_context'] = $this->options;
} else {
$data['url'] = $this->anonymizeToken(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
$data['method'] = $_SERVER['REQUEST_METHOD'] ?? null;
$data['request_id'] = $_SERVER['X-REQUEST-ID'] ?? $_SERVER['HTTP_X_REQUEST_ID'] ?? null;
}

$stderr = fopen('php://stderr', 'a');
Expand Down

0 comments on commit a777eef

Please sign in to comment.