Ejemplo n.º 1
0
 /**
  * Appends the given message along with the additional information into the log.
  *
  * @param string $message The message to log
  * @param integer $severity One of the LOG_* constants
  * @param mixed $additionalData A variable containing more information about the event to be logged
  * @param string $packageKey Key of the package triggering the log (determined automatically if not specified)
  * @param string $className Name of the class triggering the log (determined automatically if not specified)
  * @param string $methodName Name of the method triggering the log (determined automatically if not specified)
  * @return void
  * @api
  */
 public function append($message, $severity = LOG_INFO, $additionalData = NULL, $packageKey = NULL, $className = NULL, $methodName = NULL)
 {
     if ($this->number < self::MAX_LOGS) {
         $log = new Log();
         $log->setDeployment($this->deployment)->setDate(new \DateTime())->setNumber(++$this->number)->setMessage($message)->setSeverity($severity);
         $this->logRepository->add($log);
         $this->persistenceManager->persistAll();
     } elseif ($this->number === self::MAX_LOGS) {
         $log = new Log();
         $log->setDeployment($this->deployment)->setDate(new \DateTime())->setNumber(++$this->number)->setMessage('logging killed with #logs > ' . self::MAX_LOGS)->setSeverity(LOG_EMERG);
         $this->logRepository->add($log);
         $this->persistenceManager->persistAll();
     }
 }
Ejemplo n.º 2
0
 /**
  * @param Log $log
  * @return void
  */
 public function addLog(Log $log)
 {
     $log->setDeployment($this);
     $this->logs->add($log);
 }