/**
  * Dispatches a logging request.
  *
  * @param string $message  The message to log.
  * @param int    $priority The logging priority, the lower,the more
  *     important. Ranges from 1 to 7
  *
  * @return void
  */
 public function log($message, $priority = 6)
 {
     Dispatcher::getInstance()->dispatch('system.log', LogEvent::createInstance($this)->setMessage($message)->setPriority($priority));
 }
Example #2
0
 /**
  * Dispatches a logging request.
  *
  * @param string   $message  The message to log.
  * @param string   $priority The logging priority as declared in the LogLevel PSR-3 class.
  * @param string[] $parameters
  *
  * @return void
  */
 protected function log($message, $priority = LogLevel::INFO, $parameters = array())
 {
     Dispatcher::getInstance()->dispatch('system.log', LogEvent::createInstance($this->parser)->setContext($parameters)->setMessage($message)->setPriority($priority));
 }
 /**
  * @covers phpDocumentor\Event\LogEvent::setPriority
  */
 public function testOverridePriorityWithAnother()
 {
     $priority = LogLevel::ALERT;
     $this->fixture->setPriority($priority);
     $this->assertSame($priority, $this->fixture->getPriority());
 }
 /**
  * Dispatches a parser error to be logged.
  *
  * @param string   $type      The logging priority as string
  * @param string   $code      The message to log.
  * @param string   $line      The line number where the error occurred..
  * @param string[] $variables an array with message substitution variables.
  *
  * @return void
  */
 public function logParserError($type, $code, $line, $variables = array())
 {
     $message = $this->__($code, $variables);
     $this->log($message, LogLevel::ERROR);
     $this->dispatch('parser.log', LogEvent::createInstance($this)->setMessage($message)->setType($type)->setCode($code)->setLine($line));
 }
 /**
  * Dispatches a logging request.
  *
  * @param string $message  The message to log.
  * @param int    $priority The logging priority, the lower,
  *  the more important. Ranges from 1 to 7
  *
  * @return void
  */
 public function log($message, $priority = 6)
 {
     $this->dispatch('system.log', \phpDocumentor\Event\LogEvent::createInstance($this)->setMessage($message)->setPriority($priority));
 }
 /**
  * Logs an event with the output.
  *
  * This method will also colorize the message based on priority and withhold
  * certain logging in case of verbosity or not.
  *
  * @param OutputInterface $output
  * @param LogEvent        $event
  * @param Command         $command
  *
  * @return void
  */
 public function logEvent(OutputInterface $output, LogEvent $event, Command $command)
 {
     $numericErrors = array(LogLevel::DEBUG => 0, LogLevel::NOTICE => 1, LogLevel::INFO => 2, LogLevel::WARNING => 3, LogLevel::ERROR => 4, LogLevel::ALERT => 5, LogLevel::CRITICAL => 6, LogLevel::EMERGENCY => 7);
     $threshold = LogLevel::ERROR;
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
         $threshold = LogLevel::DEBUG;
     }
     if ($numericErrors[$event->getPriority()] >= $numericErrors[$threshold]) {
         /** @var Translator $translator  */
         $translator = $command->getContainer()->offsetGet('translator');
         $message = vsprintf($translator->translate($event->getMessage()), $event->getContext());
         switch ($event->getPriority()) {
             case LogLevel::WARNING:
                 $message = '<comment>' . $message . '</comment>';
                 break;
             case LogLevel::EMERGENCY:
             case LogLevel::ALERT:
             case LogLevel::CRITICAL:
             case LogLevel::ERROR:
                 $message = '<error>' . $message . '</error>';
                 break;
         }
         $output->writeln('  ' . $message);
     }
 }
Example #7
0
 /**
  * Logs an event with the output.
  *
  * This method will also colorize the message based on priority and withhold
  * certain logging in case of verbosity or not.
  *
  * @param OutputInterface $output
  * @param LogEvent        $event
  *
  * @return void.
  */
 public function logEvent(OutputInterface $output, LogEvent $event)
 {
     $threshold = \phpDocumentor\Plugin\Core\Log::ERR;
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $threshold = \phpDocumentor\Plugin\Core\Log::DEBUG;
     }
     if ($event->getPriority() <= $threshold) {
         $message = $event->getMessage();
         switch ($event->getPriority()) {
             case \phpDocumentor\Plugin\Core\Log::WARN:
                 $message = '<comment>' . $message . '</comment>';
                 break;
             case \phpDocumentor\Plugin\Core\Log::EMERG:
             case \phpDocumentor\Plugin\Core\Log::ALERT:
             case \phpDocumentor\Plugin\Core\Log::CRIT:
             case \phpDocumentor\Plugin\Core\Log::ERR:
                 $message = '<error>' . $message . '</error>';
                 break;
         }
         $output->writeln('  ' . $message);
     }
 }
 /**
  * Dispatches a logging request.
  *
  * @param string $message  The message to log.
  * @param int    $priority The logging priority, the lower,
  *  the more important. Ranges from 1 to 7
  *
  * @return void
  */
 public function log($message, $priority = 6)
 {
     if (class_exists('phpDocumentor\\Event\\Dispatcher')) {
         Dispatcher::getInstance()->dispatch('system.log', LogEvent::createInstance($this)->setMessage($message)->setPriority($priority));
     }
 }