/**
  * Apply options.
  *
  * @since 1.4.0
  */
 private function apply_options()
 {
     // Bail out if not connected yet to PHP Console.
     if (!$this->connector instanceof PhpConsole\Connector) {
         return;
     }
     // Apply 'register' option to PHP Console...
     if (true === $this->options['register'] && !class_exists('PC', false)) {
         // ...only if PC not registered yet.
         try {
             PhpConsole\Helper::register();
         } catch (\Exception $e) {
             $this->print_notice_exception($e);
         }
     }
     // Apply 'stack' option to PHP Console.
     if (true === $this->options['stack']) {
         $this->connector->getDebugDispatcher()->detectTraceAndSource = true;
     }
     // Apply 'short' option to PHP Console.
     if (true === $this->options['short']) {
         try {
             $this->connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']);
         } catch (\Exception $e) {
             $this->print_notice_exception($e);
         }
     }
 }
Esempio n. 2
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. 3
0
 private function handleDebugRecord(array $record)
 {
     $tags = $this->getRecordTags($record);
     $message = $record['message'];
     if ($record['context']) {
         $message .= ' ' . json_encode($this->connector->getDumper()->dump(array_filter($record['context'])));
     }
     $this->connector->getDebugDispatcher()->dispatchDebug($message, $tags, $this->options['classesPartialsTraceIgnore']);
 }
 public function testOptionDetectDumpTraceAndSource()
 {
     new PHPConsoleHandler(array('detectDumpTraceAndSource' => true), $this->connector);
     $this->assertTrue($this->connector->getDebugDispatcher()->detectTraceAndSource);
 }
Esempio n. 5
0
 public function testSetDebugDispatcher()
 {
     $dispatcher = new \PhpConsole\Dispatcher\Debug($this->connector, new \PhpConsole\Dumper());
     $this->connector->setDebugDispatcher($dispatcher);
     $this->assertEquals(spl_object_hash($dispatcher), spl_object_hash($this->connector->getDebugDispatcher()));
 }