Pop\Project\Project::log PHP Method

log() public method

Log the project.
public log ( string $message, integer $time = null, integer $priority = Pop\Log\Logger::INFO ) : void
$message string
$time integer
$priority integer
return void
    public function log($message, $time = null, $priority = \Pop\Log\Logger::INFO)
    {
        if (null !== $this->logger) {
            if (null !== $time) {
                $end = stripos($message, 'send') === false && (stripos($message, 'kill') !== false || stripos($message, 'end') !== false) ? PHP_EOL : null;
                $message = "[" . ($time - $this->start) . " seconds]\t\t" . $message . $end;
            }
            $this->logger->log($priority, $message);
        }
    }

Usage Example

示例#1
0
 /**
  * Finalize the request and send the response.
  *
  * @param  int   $code
  * @param  array $headers
  * @throws \Pop\Mvc\Exception
  * @return void
  */
 public function send($code = 200, array $headers = null)
 {
     if (null === $this->view) {
         throw new Exception('The view object is not defined.');
     }
     if (!$this->view instanceof View) {
         throw new Exception('The view object is not an instance of Pop\\Mvc\\View.');
     }
     if (null !== $this->project->logger()) {
         $this->project->log("Response [" . $code . "]", time());
     }
     $this->response->setCode($code);
     if (null !== $headers) {
         foreach ($headers as $name => $value) {
             $this->response->setHeader($name, $value);
         }
     }
     // Trigger any dispatch events, then send the response
     if (null !== $this->project->getEventManager()->get('dispatch')) {
         $this->project->log('[Event] Dispatch', time(), \Pop\Log\Logger::NOTICE);
     }
     $this->project->getEventManager()->trigger('dispatch', array('controller' => $this));
     $this->response->setBody($this->view->render(true));
     if (null !== $this->project->getEventManager()->get('dispatch.send')) {
         $this->project->log('[Event] Dispatch Send', time(), \Pop\Log\Logger::NOTICE);
     }
     $this->project->getEventManager()->trigger('dispatch.send', array('controller' => $this));
     $this->response->send();
 }
All Usage Examples Of Pop\Project\Project::log