/**
  * @return void
  */
 public function testFilterShouldFilterString()
 {
     $event = new Event();
     $event->setField(self::FIELD_KEY, self::VALUE_NOT_FILTERED);
     $options = [RecursiveFieldFilter::OPTION_FILTER_PATTERN => [[self::FIELD_KEY, self::FIELD_KEY, self::KEY_DO_FILTER]], RecursiveFieldFilter::OPTION_FILTERED_STR => self::VALUE_FILTERED];
     $filter = new RecursiveFieldFilter($options);
     $filter->filter($event);
     $filteredData = $event->getFields()[self::FIELD_KEY];
     $expectedData = self::VALUE_FILTERED;
     $this->assertSame($expectedData, $filteredData);
 }
Example #2
0
 /**
  * {@inheritdoc}
  *
  * @return void
  */
 public function handle(array $record)
 {
     $journal = new SharedEventJournal();
     $event = new Event();
     $event->setField('extra', $record['extra']);
     $event->setField('context', $record['context']);
     $event->setField('channel', $record['channel']);
     $event->setField('context', $record['context']);
     $event->setField('message', $record['message']);
     $event->setField('level', $record['level_name']);
     $event->setField('name', self::MESSAGE_LOG_MONOLOG);
     $journal->saveEvent($event);
 }
Example #3
0
 /**
  * @param \Exception|\Throwable $exception
  * @param \Spryker\Shared\EventJournal\Model\EventJournalInterface $eventJournal
  * @param \Spryker\Shared\NewRelic\ApiInterface $newRelicApi
  * @param bool $ignoreInternalExceptions
  *
  * @return void
  */
 protected static function sendExceptionToEventJournal($exception, EventJournalInterface $eventJournal, ApiInterface $newRelicApi, $ignoreInternalExceptions = false)
 {
     try {
         $event = new Event();
         $event->setField('message', $exception->getMessage());
         $event->setField('trace', $exception->getTraceAsString());
         $event->setField('class_name', get_class($exception));
         $event->setField('file_name', $exception->getFile());
         $event->setField('line', $exception->getLine());
         $event->setField(Event::FIELD_NAME, 'exception');
         self::addDeploymentInformation($event);
         $eventJournal->saveEvent($event);
     } catch (\Exception $internalException) {
         if (!$ignoreInternalExceptions) {
             self::sendExceptionToNewRelic($internalException, $eventJournal, $newRelicApi, true);
         }
     }
 }
 /**
  * @deprecated This method was used by logRequest() and logResponse(). You can also use the LoggerTrait.
  *
  * @param string $pathInfo
  * @param string $subType
  * @param \Spryker\Shared\ZedRequest\Client\EmbeddedTransferInterface $transfer
  * @param string $rawBody
  *
  * @return void
  */
 protected function doLog($pathInfo, $subType, EmbeddedTransferInterface $transfer, $rawBody)
 {
     if (Config::get(EventJournalConstants::DISABLE_EVENT_JOURNAL, false)) {
         return;
     }
     $eventJournal = new SharedEventJournal();
     $event = new Event();
     $responseTransfer = $transfer->getTransfer();
     if ($responseTransfer instanceof TransferInterface) {
         $event->setField(static::EVENT_FIELD_TRANSFER_DATA, $responseTransfer->modifiedToArray(true));
         $event->setField(static::EVENT_FIELD_TRANSFER_CLASS, get_class($responseTransfer));
     } else {
         $event->setField(static::EVENT_FIELD_TRANSFER_DATA, null);
         $event->setField(static::EVENT_FIELD_TRANSFER_CLASS, null);
     }
     $event->setField(Event::FIELD_NAME, 'transfer');
     $event->setField(static::EVENT_FIELD_PATH_INFO, $pathInfo);
     $event->setField(static::EVENT_FIELD_SUB_TYPE, $subType);
     $eventJournal->saveEvent($event);
 }
Example #5
0
 /**
  * @param string $pathInfo
  * @param string $subType
  * @param \Spryker\Shared\ZedRequest\Client\EmbeddedTransferInterface $transfer
  * @param string $rawBody
  *
  * @return void
  */
 protected function doLog($pathInfo, $subType, EmbeddedTransferInterface $transfer, $rawBody)
 {
     $eventJournalClient = new EventJournalClient();
     $event = new Event();
     $responseTransfer = $transfer->getTransfer();
     if ($responseTransfer instanceof TransferInterface) {
         $event->setField('transfer_data', $responseTransfer->toArray());
         $event->setField('transfer_class', get_class($responseTransfer));
     } else {
         $event->setField('transfer_data', null);
         $event->setField('transfer_class', null);
     }
     $event->setField('raw_body', $rawBody);
     $event->setField('name', 'transfer');
     $event->setField('path_info', $pathInfo);
     $event->setField('sub_type', $subType);
     $eventJournalClient->saveEvent($event);
 }