You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by gr...@apache.org on 2009/07/06 16:49:44 UTC

svn commit: r791502 - in /incubator/log4php/trunk/src/main/php: LoggerDefaultCategoryFactory.php LoggerFactory.php LoggerHierarchy.php LoggerManager.php configurators/LoggerConfiguratorIni.php configurators/LoggerConfiguratorXml.php

Author: grobmeier
Date: Mon Jul  6 14:49:44 2009
New Revision: 791502

URL: http://svn.apache.org/viewvc?rev=791502&view=rev
Log:
LOG4PHP-52 - Use of custom factorys is discouraged - clean up

Removed:
    incubator/log4php/trunk/src/main/php/LoggerDefaultCategoryFactory.php
    incubator/log4php/trunk/src/main/php/LoggerFactory.php
Modified:
    incubator/log4php/trunk/src/main/php/LoggerHierarchy.php
    incubator/log4php/trunk/src/main/php/LoggerManager.php
    incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorIni.php
    incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php

Modified: incubator/log4php/trunk/src/main/php/LoggerHierarchy.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerHierarchy.php?rev=791502&r1=791501&r2=791502&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerHierarchy.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerHierarchy.php Mon Jul  6 14:49:44 2009
@@ -88,7 +88,6 @@
 		$this->root->setHierarchy($this);
 		$this->setThreshold(LoggerLevel::getLevelAll());
 		$this->rendererMap = new LoggerRendererMap();
-		$this->defaultFactory = new LoggerDefaultCategoryFactory();		   
 	}
 	 
 	/**
@@ -131,13 +130,9 @@
 	 * @param LoggerFactory $factory a {@link LoggerFactory} instance or null	  
 	 * @return Logger
 	 */
-	public function getLogger($name, $factory = null) {
-		if($factory === null) {
-			$factory = $this->defaultFactory;
-		}
-		
+	public function getLogger($name) {
 		if(!isset($this->ht[$name])) {
-			$this->ht[$name] = $factory->makeNewLoggerInstance($name);
+			$this->ht[$name] = new Logger($name);;
 			$this->ht[$name]->setHierarchy($this);
 			$nodes = explode('.', $name);
 			$firstNode = array_shift($nodes);

Modified: incubator/log4php/trunk/src/main/php/LoggerManager.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerManager.php?rev=791502&r1=791501&r2=791502&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerManager.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerManager.php Mon Jul  6 14:49:44 2009
@@ -47,8 +47,6 @@
 	private static $_classes = array(
 		'Logger' => '/Logger.php',
 		'LoggerHierarchy' => '/LoggerHierarchy.php',
-		'LoggerDefaultCategoryFactory' => '/LoggerDefaultCategoryFactory.php',
-		'LoggerHierarchy' => '/LoggerHierarchy.php',
 		'LoggerLayout' => '/LoggerLayout.php',
 		'LoggerLevel' => '/LoggerLevel.php',
 		'LoggerMDC' => '/LoggerMDC.php',
@@ -102,7 +100,6 @@
 		'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php',
 		'LoggerRendererObject' => '/renderers/LoggerRendererObject.php',
 		'LoggerRendererMap' => '/renderers/LoggerRendererMap.php',
-		'LoggerFactory' => '/LoggerFactory.php',
 		'LoggerLocationInfo' => '/LoggerLocationInfo.php',
 		'LoggerLoggingEvent' => '/LoggerLoggingEvent.php',
 		'LoggerFilter' => '/LoggerFilter.php',

Modified: incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorIni.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorIni.php?rev=791502&r1=791501&r2=791502&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorIni.php (original)
+++ incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorIni.php Mon Jul  6 14:49:44 2009
@@ -85,16 +85,11 @@
 	const LOGGER_FACTORY_KEY = "log4php.loggerFactory";
 	const LOGGER_DEBUG_KEY = "log4php.debug";
 	const INTERNAL_ROOT_NAME = "root";
-	/**
-	 * @var LoggerFactory
-	 */
-	private $loggerFactory = null;
 	
 	/**
 	 * Constructor
 	 */
 	public function __construct() {
-		$this->loggerFactory = new LoggerDefaultCategoryFactory();
 	}
 	
 	/**
@@ -339,7 +334,6 @@
 		$hierarchy->setThreshold(LoggerOptionConverter::toLevel($thresholdStr, LoggerLevel::getLevelAll()));
 		
 		$this->configureRootCategory($properties, $hierarchy);
-		$this->configureLoggerFactory($properties);
 		$this->parseCatsAndRenderers($properties, $hierarchy);
 
 		return true;
@@ -348,35 +342,6 @@
 	// --------------------------------------------------------------------------
 	// Internal stuff
 	// --------------------------------------------------------------------------
-
-	/**
-	 * Check the provided <b>Properties</b> object for a
-	 * {@link LoggerFactory} entry specified by 
-	 * {@link LOGGER_FACTORY_KEY}.
-	 *	
-	 * If such an entry exists, an attempt is made to create an instance using 
-	 * the default constructor.	 
-	 * This instance is used for subsequent Category creations
-	 * within this configurator.
-	 *
-	 * @see parseCatsAndRenderers()
-	 * @param array $props array of properties
-	 */
-	private function configureLoggerFactory($props) {
-		$factoryFqcn = @$props[self::LOGGER_FACTORY_KEY];
-		if(!empty($factoryFqcn)) {
-			$factoryClassName = basename($factoryFqcn);
-			
-			if(class_exists($factoryClassName)) {
-				$loggerFactory = new $factoryClassName();
-			} else {
-				// LoggerPropertyConfigurator::configureLoggerFactory() Unable to load factory
-				$loggerFactory = $this->loggerFactory;
-			}
-
-			LoggerReflectionUtils::setPropertiesByObject($loggerFactory, $props, self::FACTORY_PREFIX . ".");
-		}
-	}
 	
 	/**
 	 * @param array $props array of properties
@@ -426,7 +391,7 @@
 					$loggerName = substr($key, strlen(self::LOGGER_PREFIX));
 				}
 				
-				$logger = $hierarchy->getLogger($loggerName, $this->loggerFactory);
+				$logger = $hierarchy->getLogger($loggerName);
 					// synchronized(logger) {
 					$this->parseCategory($props, $logger, $key, $loggerName, $value);
 					$this->parseAdditivityForLogger($props, $logger, $loggerName);

Modified: incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php?rev=791502&r1=791501&r2=791502&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php (original)
+++ incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php Mon Jul  6 14:49:44 2009
@@ -274,32 +274,7 @@
                 
                 $loggerName = $this->subst(@$attribs['NAME']);
                 if (!empty($loggerName)) {
-                    $class = $this->subst(@$attribs['CLASS']);
-                    if (empty($class)) {
-                        $this->logger = $this->repository->getLogger($loggerName);
-                    } else {
-                        $className = basename($class);
-                        if (!class_exists($className)) {
-                        	// TODO throw exception?
-                            /*LoggerLog::warn(
-                                "LoggerDOMConfigurator::tagOpen() LOGGER. ".
-                                "cannot find '$className'."
-                            );*/                        
-                        } else {
-                        
-                            if (in_array('getlogger', get_class_methods($className))) {
-                                $this->logger = call_user_func(array($className, 'getlogger'), $loggerName);
-                            } else {
-                            	// TODO throw exception?
-                            	/*
-                                LoggerLog::warn(
-                                    "LoggerDOMConfigurator::tagOpen() LOGGER. ".
-                                    "class '$className' doesnt implement 'getLogger()' method."
-                                );
-                                */                        
-                            }
-                        }
-                    }    
+                    $this->logger = $this->repository->getLogger($loggerName);
                     if ($this->logger !== null and isset($attribs['ADDITIVITY'])) {
                         $additivity = LoggerOptionConverter::toBoolean($this->subst($attribs['ADDITIVITY']), true);     
                         $this->logger->setAdditivity($additivity);