public function testAddRenderer()
 {
     $hierarchy = Logger::getHierarchy();
     //print_r($hierarchy);
     LoggerRendererMap::addRenderer($hierarchy, 'string', 'LoggerRendererDefault');
     //print_r($hierarchy);
     self::markTestIncomplete();
 }
예제 #2
0
 /**
  * Reset all values contained in this hierarchy instance to their
  * default. 
  *
  * This removes all appenders from all loggers, sets
  * the level of all non-root loggers to <i>null</i>,
  * sets their additivity flag to <i>true</i> and sets the level
  * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
  * 
  * <p>Existing loggers are not removed. They are just reset.
  *
  * <p>This method should be used sparingly and with care as it will
  * block all logging until it is completed.</p>
  */
 public function resetConfiguration()
 {
     $root = $this->getRootLogger();
     $root->setLevel(LoggerLevel::getLevelDebug());
     $this->setThreshold(LoggerLevel::getLevelAll());
     $this->shutDown();
     foreach ($this->loggers as $logger) {
         $logger->setLevel(null);
         $logger->setAdditivity(true);
         $logger->removeAllAppenders();
     }
     $this->rendererMap->reset();
     LoggerAppenderPool::clear();
 }
 /**
  * Parse non-root elements, such non-root categories and renderers.
  *
  * @param array $props array of properties
  * @param LoggerHierarchy &$hierarchy
  */
 function parseCatsAndRenderers($props, &$hierarchy)
 {
     while (list($key, $value) = each($props)) {
         if (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0 or strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) {
             if (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX) === 0) {
                 $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_CATEGORY_PREFIX));
             } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX) === 0) {
                 $loggerName = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_LOGGER_PREFIX));
             }
             $logger =& $hierarchy->getLogger($loggerName, $this->loggerFactory);
             // synchronized(logger) {
             $this->parseCategory($props, $logger, $key, $loggerName, $value);
             $this->parseAdditivityForLogger($props, $logger, $loggerName);
             // }
         } elseif (strpos($key, LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX) === 0) {
             $renderedClass = substr($key, strlen(LOG4PHP_LOGGER_PROPERTY_CONFIGURATOR_RENDERER_PREFIX));
             $renderingClass = $value;
             if (method_exists($hierarchy, 'addrenderer')) {
                 LoggerRendererMap::addRenderer($hierarchy, $renderedClass, $renderingClass);
             }
         }
     }
 }
예제 #4
0
 /**
  * Used by subclasses to add a renderer to the hierarchy passed as parameter.
  * @param string $renderedClass a LoggerRenderer class name
  * @param LoggerRenderer $renderer
  *
  */
 function setRenderer($renderedClass, $renderer)
 {
     $this->rendererMap->put($renderedClass, $renderer);
 }
 /**
  * Parse non-root elements, such non-root categories and renderers.
  *
  * @param array $props array of properties
  * @param LoggerHierarchy $hierarchy
  */
 private function parseCatsAndRenderers($props, LoggerHierarchy $hierarchy)
 {
     while (list($key, $value) = each($props)) {
         if (strpos($key, self::CATEGORY_PREFIX) === 0 or strpos($key, self::LOGGER_PREFIX) === 0) {
             if (strpos($key, self::CATEGORY_PREFIX) === 0) {
                 $loggerName = substr($key, strlen(self::CATEGORY_PREFIX));
             } else {
                 if (strpos($key, self::LOGGER_PREFIX) === 0) {
                     $loggerName = substr($key, strlen(self::LOGGER_PREFIX));
                 }
             }
             $logger = $hierarchy->getLogger($loggerName);
             $this->parseCategory($props, $logger, $key, $loggerName, $value);
             $this->parseAdditivityForLogger($props, $logger, $loggerName);
         } else {
             if (strpos($key, self::RENDERER_PREFIX) === 0) {
                 $renderedClass = substr($key, strlen(self::RENDERER_PREFIX));
                 $renderingClass = $value;
                 if (method_exists($hierarchy, 'addrenderer')) {
                     // ?
                     LoggerRendererMap::addRenderer($hierarchy, $renderedClass, $renderingClass);
                 }
             }
         }
     }
 }
 public function testExceptionRenderer()
 {
     $ex = new LoggerException("This is a test");
     $map = new LoggerRendererMap();
     $actual = $map->findAndRender($ex);
     $expected = (string) $ex;
     self::assertSame($expected, $actual);
 }