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/05/23 18:53:31 UTC

svn commit: r777962 - in /incubator/log4php/trunk/src/main/php: Logger.php LoggerHierarchy.php LoggerRoot.php

Author: grobmeier
Date: Sat May 23 16:53:31 2009
New Revision: 777962

URL: http://svn.apache.org/viewvc?rev=777962&view=rev
Log:
cleaned up: removed unnecessary methods, safed encapsulation, more php5 syntax

Modified:
    incubator/log4php/trunk/src/main/php/Logger.php
    incubator/log4php/trunk/src/main/php/LoggerHierarchy.php
    incubator/log4php/trunk/src/main/php/LoggerRoot.php

Modified: incubator/log4php/trunk/src/main/php/Logger.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/Logger.php?rev=777962&r1=777961&r2=777962&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/Logger.php (original)
+++ incubator/log4php/trunk/src/main/php/Logger.php Sat May 23 16:53:31 2009
@@ -1,5 +1,5 @@
 <?php
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements. See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -23,55 +23,51 @@
  */
 
 /**
- * This class has been deprecated and replaced by the Logger subclass.
+ * This is the central class in the log4j package. Most logging operations, 
+ * except configuration, are done through this class. 
+ *
+ * In log4j this class replaces the Category class. There is no need to 
+ * port deprecated classes; log4php Logger class doesn't extend Category.
  *
  * @version		 $Revision$
  * @package log4php
- * @see Logger
  */
+ /*
+  * TODO:
+  * Localization: setResourceBundle($bundle) : not supported
+  * Localization: l7dlog($priority, $key, $params, $t) : not supported
+  */
 class Logger {
-
 	/**
 	 * Additivity is set to true by default, that is children inherit the 
 	 * appenders of their ancestors by default.
 	 * @var boolean
 	 */
-	protected $additive = true;
+	private $additive = true;
 	
-	/**
-	 * @var string fully qualified class name
-	 */
-	protected $fqcn = 'LoggerCategory';
+	/** @var string fully qualified class name */
+	private $fqcn = 'Logger';
 
-	/**
-	 * @var LoggerLevel The assigned level of this category.
-	 */
-	var $level = null;
+	/** @var LoggerLevel The assigned level of this category. */
+	private $level = null;
 	
-	/**
-	 * @var string name of this category.
-	 */
-	protected $name = '';
+	/** @var string name of this category. */
+	private $name = '';
 	
-	/**
-	 * @var Logger The parent of this category.
-	 */
-	protected $parent = null;
+	/** @var Logger The parent of this category. Null if this is the root logger*/
+	private $parent = null;
 
-	/**
-	 * @var LoggerHierarchy the object repository
-	 */
-	var $repository = null; 
+	/** @var LoggerHierarchy the object repository */
+	private $repository = null; 
 
 	/**
 	 * @var array collection of appenders
 	 * @see LoggerAppender
 	 */
-	var $aai = array();
+	private $aai = array();
 
 	/**
 	 * Constructor.
-	 *
 	 * @param  string  $name  Category name	  
 	 */
 	public function __construct($name) {
@@ -220,14 +216,6 @@
 	}
   
 	/**
-	 * Retrieve a category with named as the name parameter.
-	 * @return Logger
-	 */
-	public function getInstance($name) {
-		return LoggerManager::getLogger($name);
-	}
-
-	/**
 	 * Returns the assigned Level, if any, for this Category.
 	 * @return LoggerLevel or null 
 	 */
@@ -237,6 +225,7 @@
 	
 	/**
 	 * Get a Logger by name (Delegate to {@link LoggerManager})
+	 * 
 	 * @param string $name logger name
 	 * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
 	 * @return Logger
@@ -365,13 +354,6 @@
 	} 
 
 	/**
-	 * Log a localized and parameterized message.
-	 */
-	public function l7dlog($priority, $key, $params, $t) {
-		return;
-	} 
-
-	/**
 	 * This generic form is intended to be used by wrappers.
 	 *
 	 * @param LoggerLevel $priority a valid level
@@ -441,18 +423,12 @@
 		$this->level = $level;
 	}
 	
-	public function setParent($logger) {
-		if($logger instanceof Logger) {
-			$this->parent = $logger;
-		}
-	} 
-
 	/**
-	 * Set the resource bundle to be used with localized logging methods 
+	 * Sets the parent logger of this logger
 	 */
-	public function setResourceBundle($bundle) {
-		return;
-	}
+	public function setParent(Logger $logger) {
+			$this->parent = $logger;
+	} 
 
 	/**
 	 * Log a message with the WARN level.

Modified: incubator/log4php/trunk/src/main/php/LoggerHierarchy.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerHierarchy.php?rev=777962&r1=777961&r2=777962&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerHierarchy.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerHierarchy.php Sat May 23 16:53:31 2009
@@ -133,20 +133,9 @@
 	 */
 	public function getLogger($name, $factory = null) {
 		if($factory === null) {
-			return $this->getLoggerByFactory($name, $this->defaultFactory);
-		} else {
-			return $this->getLoggerByFactory($name, $factory);
+			$factory = $this->defaultFactory;
 		}
-	} 
-	
-	/**
-	 * Return a new logger instance named as the first parameter using the default factory.
-	 * 
-	 * @param string $name logger name
-	 * @return Logger
-	 * @todo merge with {@link getLogger()}
-	 */
-	private function getLoggerByFactory($name, $factory) {
+		
 		if(!isset($this->ht[$name])) {
 			$this->ht[$name] = $factory->makeNewLoggerInstance($name);
 			$this->ht[$name]->setHierarchy($this);
@@ -174,7 +163,7 @@
 			}
 		}			 
 		return $this->ht[$name];
-	}
+	} 
 	
 	/**
 	 * @return LoggerRendererMap Get the renderer map for this hierarchy.
@@ -235,7 +224,6 @@
 		for($i = 0; $i < $enumLoggers; $i++) {
 			$loggers[$i]->setLevel(null);
 			$loggers[$i]->setAdditivity(true);
-			$loggers[$i]->setResourceBundle(null);
 			$loggers[$i]->removeAllAppenders();
 		}
 		$this->rendererMap->clear();

Modified: incubator/log4php/trunk/src/main/php/LoggerRoot.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerRoot.php?rev=777962&r1=777961&r2=777962&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerRoot.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerRoot.php Sat May 23 16:53:31 2009
@@ -38,7 +38,6 @@
 	 */
 	protected $parent = null;
 	
-
 	/**
 	 * Constructor
 	 *
@@ -56,7 +55,7 @@
 	 * @return LoggerLevel the level
 	 */
 	public function getChainedLevel() {
-		return $this->level;
+		return parent::getLevel();
 	} 
 	
 	/**
@@ -65,7 +64,7 @@
 	 */
 	public function setLevel($level) {
 		if($level != null) {
-			$this->level = $level;
+			parent::setLevel($level);
 		}	 
 	}