Esempio n. 1
0
 /**
  * Logs with an arbitrary level.
  *
  */
 public function log($level, $message, array $context = array())
 {
     if (is_object($message) && is_callable($message, '__toString')) {
         $message = (string) $message;
     }
     $message = $this->fetchMessageContext($message, $context);
     if (isset(static::$debugLevels[$level])) {
         $this->connector->getDebugDispatcher()->dispatchDebug($message, static::$debugLevels[$level], null);
     } elseif (isset(static::$errorsLevels[$level])) {
         if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
             $this->connector->getErrorsDispatcher()->dispatchException($context['exception']);
         } else {
             $this->connector->getErrorsDispatcher()->dispatchError(static::$errorsLevels[$level], $message, null, null, null);
         }
     } else {
         throw new \Psr\Log\InvalidArgumentException('Unknown log level "' . $level . '"');
     }
 }
Esempio n. 2
0
 public function testRecursiveExceptionsHandlingLimit()
 {
     $handler = $this->handler;
     set_exception_handler(function () use($handler) {
         $handler->handleException(new \Exception());
     });
     $this->connector->getErrorsDispatcher()->ignoreRepeatedSource = false;
     $this->connector->expects($this->exactly(\PhpConsole\Handler::ERRORS_RECURSION_LIMIT))->method('sendMessage');
     $this->handler->start();
     $this->handler->handleException(new \Exception());
 }
Esempio n. 3
0
 private function handleErrorRecord(array $record)
 {
     $context = $record['context'];
     $this->connector->getErrorsDispatcher()->dispatchError(isset($context['code']) ? $context['code'] : null, isset($context['message']) ? $context['message'] : $record['message'], isset($context['file']) ? $context['file'] : null, isset($context['line']) ? $context['line'] : null, $this->options['classesPartialsTraceIgnore']);
 }
Esempio n. 4
0
 public function testSetErrorsDispatcher()
 {
     $dispatcher = new \PhpConsole\Dispatcher\Errors($this->connector, new \PhpConsole\Dumper());
     $this->connector->setErrorsDispatcher($dispatcher);
     $this->assertEquals(spl_object_hash($dispatcher), spl_object_hash($this->connector->getErrorsDispatcher()));
 }