/**
  * @param \Silex\Application $app
  *
  * @return void
  */
 public function register(Application $app)
 {
     if ((int) Config::get(ApplicationConstants::LOG_LEVEL) === 0) {
         return;
     }
     $app['logger'] = function () use($app) {
         return $app['monolog'];
     };
     $app['monolog.logger.class'] = 'Monolog\\Logger';
     $app['monolog'] = $app->share(function ($app) {
         $log = new $app['monolog.logger.class']($app['monolog.name']);
         $log->pushHandler($app['monolog.handler']);
         if ($app['debug']) {
             $log->pushHandler($app['monolog.handler.debug']);
         }
         return $log;
     });
     $app['monolog.logfile'] = function () {
         return Log::getFilePath('message.log');
     };
     $app['monolog.handler.debug'] = function () use($app) {
         return new StreamHandler($app['monolog.logfile'], $app['monolog.level']);
     };
     $app['monolog.handler'] = function () use($app) {
         return new EventJournalHandler($app['monolog.level']);
     };
     $app['monolog.level'] = function () {
         return Logger::INFO;
     };
     $app['monolog.name'] = 'yves';
 }
Esempio n. 2
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem
  *
  * @return bool
  */
 public function check(SpySalesOrderItem $orderItem)
 {
     $b = microtime() * 1000000 % 2 ? true : false;
     $bS = $b ? 'true' : 'false';
     Log::log('Condition PaymentRedirected for item: ' . $orderItem->getIdSalesOrderItem() . ' ' . $bS, 'statemachine.log');
     return $b;
 }
Esempio n. 3
0
 /**
  * @param \Spryker\Shared\ZedRequest\Client\RequestInterface $transferObject
  * @param \Symfony\Component\HttpFoundation\Request $httpRequest
  *
  * @return void
  */
 public function setRepeatData(RequestInterface $transferObject, HttpRequest $httpRequest)
 {
     if ($this->isRepeatInProgress) {
         return;
     }
     if (Config::get(ApplicationConstants::SET_REPEAT_DATA, false) === false) {
         return;
     }
     $repeatData = ['module' => $httpRequest->attributes->get('module'), 'controller' => $httpRequest->attributes->get('controller'), 'action' => $httpRequest->attributes->get('action'), 'params' => $transferObject->toArray(false)];
     $mvc = sprintf('%s_%s_%s', $httpRequest->attributes->get('module'), $httpRequest->attributes->get('controller'), $httpRequest->attributes->get('action'));
     Log::setFlashInFile($repeatData, 'last_yves_request_' . $mvc . '.log');
     Log::setFlashInFile($repeatData, 'last_yves_request.log');
 }
Esempio n. 4
0
 /**
  * @param string $url
  * @param string $body
  *
  * @return string
  */
 private function callJenkins($url, $body = '')
 {
     $post_url = Config::get(SetupConstants::JENKINS_BASE_URL) . '/' . $url;
     //createItem?name=" . $v['name'];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $post_url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: text/xml']);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     Log::logRaw('CURL call: ' . $post_url . "body:\n[" . $body . "]\n\n", self::LOGFILE);
     $head = curl_exec($ch);
     Log::logRaw("CURL response:\n[" . $head . "]\n\n", self::LOGFILE);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     return $httpCode;
 }
Esempio n. 5
0
 /**
  * @param \Exception|\Throwable $exception
  * @param \Spryker\Shared\EventJournal\Model\EventJournalInterface $eventJournal
  * @param \Spryker\Shared\NewRelic\ApiInterface $newRelicApi
  *
  * @return void
  */
 protected static function sendExceptionToFile($exception, EventJournalInterface $eventJournal, ApiInterface $newRelicApi)
 {
     try {
         $message = ErrorRenderer::renderException($exception);
         Log::log($message, 'exception.log');
     } catch (\Exception $internalException) {
         self::sendExceptionToEventJournal($internalException, $eventJournal, $newRelicApi, true);
         self::sendExceptionToNewRelic($internalException, $eventJournal, $newRelicApi, true);
     }
 }
Esempio n. 6
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $orderItems
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
  * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
  *
  * @return array
  */
 public function run(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)
 {
     $message = sprintf('Command SendOrderConfirmation by Order for Order %s (%s items)', $orderEntity->getIdSalesOrder(), count($orderItems));
     Log::log($message, 'statemachine.log');
     return [];
 }
Esempio n. 7
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem
  * @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data
  *
  * @return array
  */
 public function run(SpySalesOrderItem $orderItem, ReadOnlyArrayObject $data)
 {
     $message = sprintf('Command DecreaseStock by Item for Item %s (quantity %s)', $orderItem->getIdSalesOrderItem(), $orderItem->getQuantity());
     Log::log($message, 'statemachine.log');
     return [];
 }
Esempio n. 8
0
 /**
  * @param \DateTime $currentTime
  * @param \Spryker\Zed\Oms\Business\Process\EventInterface $event
  *
  * @return \DateTime
  */
 protected function calculateTimeoutDateFromEvent(DateTime $currentTime, EventInterface $event)
 {
     $currentTime = clone $currentTime;
     if (!isset($this->eventToTimeoutBuffer[$event->getName()])) {
         $timeout = $event->getTimeout();
         $interval = DateInterval::createFromDateString($timeout);
         $this->validateTimeout($interval, $timeout);
         $this->eventToTimeoutBuffer[$event->getName()] = $currentTime->add($interval);
         Log::log($this->eventToTimeoutBuffer, 'timeout.log');
     }
     return $this->eventToTimeoutBuffer[$event->getName()];
 }