/** {@inheritdoc} */
 public function process(Metadata $metadata, \Exception $exception = null)
 {
     $metadata->setStage($this->environment);
     $metadata->addTag('symfony_version', Kernel::VERSION);
     $metadata->addMetadatum('symfony_version', Kernel::VERSION);
     $metadata->setAppRootDir($this->kernelRootDir);
 }
Ejemplo n.º 2
0
 /** {@inheritdoc} */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $type = $input->getOption('type');
     if (!in_array($type, array('error', 'exception'))) {
         throw new \LogicException('Type must be either "error" or "exception"');
     }
     $count = intval($input->getOption('count'));
     $digits = floor(log10($count) + 1);
     /** @var ErrorHandler $errorHandler */
     $errorHandler = $this->getContainer()->get('error_handler');
     $metadata = new Metadata();
     $metadata->addCategories($input->getArgument('category'));
     $output->writeln('<fg=cyan>Creating errors</fg=cyan>');
     for ($i = 1; $i <= $count; ++$i) {
         switch ($type) {
             case 'error':
                 $error = new ErrorException('TEST ERROR', E_USER_ERROR, __FILE__, __LINE__);
                 $errorHandler->handleError($error, $metadata);
                 break;
             case 'exception':
                 $errorHandler->handleException(new \Exception(), $metadata);
                 break;
         }
         $output->writeln(sprintf("<comment>[%{$digits}d/%{$digits}d]</comment> <info>OK</info>", $i, $count));
     }
     $output->writeln('<info>DONE</info>');
 }
Ejemplo n.º 3
0
 public function testSkipping()
 {
     $this->assertEquals(0, $this->errorHandler->getStats()->getEventsHandled());
     $metadata = new Metadata();
     $metadata->setAction(Metadata::ACTION_SKIP);
     $this->errorHandler->handleEvent('event', $metadata);
     $this->assertEquals(0, $this->errorHandler->getStats()->getEventsHandled());
 }
 /**
  * @param ConsoleExceptionEvent $event
  */
 public function onConsoleException(ConsoleExceptionEvent $event)
 {
     $exception = $event->getException();
     $metadata = new Metadata();
     $metadata->addMetadatum('commandName', $event->getInput()->getFirstArgument());
     $metadata->addMetadatum('command', (string) $event->getInput());
     $metadata->addMetadatum('exitCode', $event->getExitCode());
     $this->errorHandler->handleException($exception, $metadata);
 }
Ejemplo n.º 5
0
 /**
  * @param Metadata $metadata
  *
  * @return Metadata
  */
 protected function addDefaultCategory(Metadata $metadata = null)
 {
     if (null === $metadata) {
         $metadata = new Metadata();
     }
     if (array() === $metadata->getCategories()) {
         $metadata->addCategory('default');
     }
     return $metadata;
 }
Ejemplo n.º 6
0
 /**
  * @param Metadata $metadata
  *
  * @return string
  */
 protected function calculateGroupingHash(Metadata $metadata)
 {
     $grouping = $metadata->getGrouping();
     if (!$grouping) {
         return '';
     }
     $dataToHash = '';
     foreach ($grouping as $name => $value) {
         $dataToHash .= sprintf('%s=%s', $name, serialize($value));
     }
     return md5($dataToHash);
 }
 /** {@inheritdoc} */
 public function process(Metadata $metadata, \Exception $exception = null)
 {
     $metadata->addTag('php_version', phpversion());
     $metadata->addMetadatum('php_version', phpversion());
     $metadata->addTag('php_sapi_name', php_sapi_name());
     $metadata->addMetadatum('php_sapi_name', php_sapi_name());
     $metadata->addTag('hostname', gethostname());
     $metadata->addMetadatum('hostname', gethostname());
 }
Ejemplo n.º 8
0
 /** {@inheritdoc} */
 public function process(Metadata $metadata, \Exception $exception = null)
 {
     $this->callbackExecuted = true;
     $metadata->setAppRootDir('app_root_dir');
     $metadata->setStage('stage');
     $metadata->setAppVersion('app_version');
     $metadata->addTags(array('tag1' => 1, 'tag3' => 3));
     $metadata->addTag('tag2', 2);
     $metadata->removeTag('tag3');
     $metadata->addMetadata(array('metadatum1' => 1, 'metadatum3' => 3));
     $metadata->addMetadatum('metadatum2', 2);
     $metadata->removeMetadatum('metadatum3');
     $metadata->addCategories(array('category1', 'category2'));
     $metadata->addCategory('category3');
     $metadata->removeCategory('category3');
     $metadata->addGrouping(array('group1' => 'value1'));
     $metadata->groupBy('group1', 'value2');
     $metadata->groupBy('group2', 'value2');
 }
Ejemplo n.º 9
0
 /**
  * @param Metadata $metadata
  *
  * @return bool
  */
 protected function shouldHandle(Metadata $metadata)
 {
     return Metadata::ACTION_PROCESS === $metadata->getAction();
 }