Esempio n. 1
0
 /**
  * PHP magic method that returns the string representation of this object.
  * @return string the string representation of this object.
  */
 public function __toString()
 {
     // __toString cannot throw exception
     // use trigger_error to bypass this limitation
     try {
         return $this->toString();
     } catch (\Exception $e) {
         ErrorHandler::convertExceptionToError($e);
         return '';
     }
 }
Esempio n. 2
0
 /**
  * Dispatches the logged messages to [[targets]].
  *
  * @param array $messages the logged messages
  * @param boolean $final whether this method is called at the end of the current application
  */
 public function dispatch($messages, $final)
 {
     $targetErrors = [];
     foreach ($this->targets as $target) {
         if ($target->enabled) {
             try {
                 $target->collect($messages, $final);
             } catch (\Exception $e) {
                 $target->enabled = false;
                 $targetErrors[] = ['Unable to send log via ' . get_class($target) . ': ' . ErrorHandler::convertExceptionToString($e), Logger::LEVEL_WARNING, __METHOD__, microtime(true), []];
             }
         }
     }
     if (!empty($targetErrors)) {
         $this->dispatch($targetErrors, true);
     }
 }