/**
  * 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)
 {
     \phpDocumentor\Plugin\EventDispatcher::getInstance()->dispatch('system.log', \phpDocumentor\Events\LogEvent::createInstance($this)->setMessage($message)->setPriority($priority));
 }
Exemple #2
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 \sfEvent $event
  *
  * @return void.
  */
 public function logEvent(OutputInterface $output, \phpDocumentor\Events\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);
     }
 }