Conversation
| @mkdir($reportDirName, 0777, true); | ||
| } | ||
| $this->_setReportData($reportData); | ||
| // $reportDirName = dirname($this->_reportFile); |
There was a problem hiding this comment.
Maybe let's disable it by env variable? So Cloud can utilize this and disable writing reports to files.
| <arguments> | ||
| <argument name="formatter" xsi:type="object">Magento\Framework\Logger\Formatter\JsonFormatter</argument> | ||
| <argument name="stream" xsi:type="string">php://stdout</argument> | ||
| <argument name="level" xsi:type="const">Monolog\Logger::DEBUG</argument> |
There was a problem hiding this comment.
As I understand, this means all messages of level "debug" and higher will be logged.
This makes sense for dev environment, but is usually configured differently in production. It would be good to have an ability to configure level of logging from env variable (or env.php).
| { | ||
| /** @var \Psr\Log\LoggerInterface $logger */ | ||
| $logger = $this->_objectManager->get(\Psr\Log\LoggerInterface::class); | ||
| $logger->error($exception, ['bootstrap' => $bootstrap]); |
There was a problem hiding this comment.
Looks like it duplicates logic of the client code.
// \Magento\Framework\App\Bootstrap::run()
$this->objectManager->get(LoggerInterface::class)->error($e->getMessage());
if (!$application->catchException($this, $e)) {
throw $e;
}
| /** | ||
| * Class Monolog | ||
| */ | ||
| class Monolog extends LoggerAbstract |
There was a problem hiding this comment.
It probably shouldn't be "Monolog", as it just uses PSR logger interface. Not sure if it should be "PsrLogger" :) or something else.
| */ | ||
| public function format(array $record) | ||
| { | ||
| if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { |
There was a problem hiding this comment.
Btw, we should take into account \Throwable as well now. Or we'll miss errors.
I see that Monolog's JsonFormatter takes this into account when checking the $data.
if ($data instanceof Exception || $data instanceof Throwable) {
return $this->normalizeException($data);
}
| <argument name="formatter" xsi:type="object">Magento\Framework\Logger\Formatter\JsonFormatter</argument> | ||
| <argument name="stream" xsi:type="string">php://stdout</argument> | ||
| <argument name="level" xsi:type="const">Monolog\Logger::DEBUG</argument> | ||
| <!-- <argument name="level" xsi:type="const">Monolog\Logger::ERROR</argument>--> |
| $reportId = abs((int)(microtime(true) * random_int(100, 1000))); | ||
| $this->directoryWrite->writeFile('report/api/' . $reportId, $this->serializer->serialize($reportData)); | ||
| // $this->directoryWrite->create('report/api'); | ||
| $reportId = (string)abs((int)(microtime(true) * random_int(100, 1000))); |
There was a problem hiding this comment.
Please replace with $reportId = md5($reportData);
| // } | ||
| // $this->_setReportData($reportData); | ||
|
|
||
| @file_put_contents($this->_reportFile, $this->serializer->serialize($reportData). PHP_EOL); |
There was a problem hiding this comment.
Reporting needed only in Development Env.
For production better to use NewRelic APM/OpenTracing sollution
No description provided.