logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject svn commit: r1166182 - in /logging/log4php/trunk/src/main/php: ./ appenders/
Date Wed, 07 Sep 2011 13:49:35 GMT
Author: ihabunek
Date: Wed Sep  7 13:49:35 2011
New Revision: 1166182

URL: http://svn.apache.org/viewvc?rev=1166182&view=rev
Log:
LOG4PHP-151: Moved common appender methods to parent LoggerAppender class; improved LoggerAppender
documentation. No changes to function.

Modified:
    logging/log4php/trunk/src/main/php/LoggerAppender.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderConsole.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderDailyFile.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderEcho.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderFile.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMail.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMailEvent.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMongoDB.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderNull.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPDO.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPhp.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php
    logging/log4php/trunk/src/main/php/appenders/LoggerAppenderSocket.php

Modified: logging/log4php/trunk/src/main/php/LoggerAppender.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/LoggerAppender.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/LoggerAppender.php (original)
+++ logging/log4php/trunk/src/main/php/LoggerAppender.php Wed Sep  7 13:49:35 2011
@@ -27,62 +27,77 @@
 abstract class LoggerAppender {
 	
 	/**
-	 * @var boolean closed appender flag
+	 * Set to true when the appender is closed. A closed appender will not 
+	 * accept any logging requests. 
+	 * @var boolean 
 	 */
 	protected $closed = false;
 	
 	/**
-	 * The first filter in the filter chain
+	 * The first filter in the filter chain.
 	 * @var LoggerFilter
 	 */
 	protected $filter = null;
 			
 	/**
-	 * LoggerLayout for this appender. It can be null if appender has its own layout
+	 * The appender's layout. Can be null if the appender does not use 
+	 * a layout.
 	 * @var LoggerLayout
 	 */
 	protected $layout = null; 
 	
 	/**
-	 * @var string Appender name
+	 * Appender name. Used by other components to identify this appender.
+	 * @var string
 	 */
 	protected $name;
 	
 	/**
-	 * @var LoggerLevel There is no level threshold filtering by default.
+	 * Appender threshold level. Events whose level is below the threshold 
+	 * will not be logged.
+	 * @var LoggerLevel
 	 */
 	protected $threshold = null;
 	
 	/**
-	 * @var boolean needs a layout formatting ?
+	 * Set to true if the appender requires a layout.
+	 * 
+	 * True by default, appenders which do not use a layout should override 
+	 * this property to false.
+	 * 
+	 * @var boolean
 	 */
 	protected $requiresLayout = true;
 	
 	/**
-	 * Constructor
-	 *
-	 * @param string $name appender name
+	 * Default constructor.
+	 * @param string $name Appender name
 	 */
 	public function __construct($name = '') {
 		$this->name = $name;
 	}
+	
+	/**
+	 * Default destructor; closes the appender.
+	 */
+	public function __destruct() {
+		$this->close();
+	}
 
 	/**
-	 * Add a filter to the end of the filter list.
-	 *
-	 * @param LoggerFilter $newFilter add a new LoggerFilter
+	 * Adds a filter to the end of the filter chain.
+	 * @param LoggerFilter $filter add a new LoggerFilter
 	 */
-	public function addFilter($newFilter) {
+	public function addFilter($filter) {
 		if($this->filter === null) {
-			$this->filter = $newFilter;
+			$this->filter = $filter;
 		} else {
-			$this->filter->addNext($newFilter);
+			$this->filter->addNext($filter);
 		}
 	}
 	
 	/**
-	 * Clear the list of filters by removing all the filters in it.
-	 * @abstract
+	 * Clears the filter chain by removing all the filters in it.
 	 */
 	public function clearFilters() {
 		unset($this->filter);
@@ -90,7 +105,7 @@ abstract class LoggerAppender {
 	}
 
 	/**
-	 * Return the first filter in the filter chain for this Appender. 
+	 * Returns the first filter in the filter chain. 
 	 * The return value may be <i>null</i> if no is filter is set.
 	 * @return LoggerFilter
 	 */
@@ -99,7 +114,7 @@ abstract class LoggerAppender {
 	} 
 	
 	/** 
-	 * Return the first filter in the filter chain for this Appender. 
+	 * Returns the first filter in the filter chain. 
 	 * The return value may be <i>null</i> if no is filter is set.
 	 * @return LoggerFilter
 	 */
@@ -107,11 +122,10 @@ abstract class LoggerAppender {
 		return $this->filter;
 	}
 	
-	
 	/**
-	 * This method performs threshold checks and invokes filters before
-	 * delegating actual logging to the subclasses specific <i>append()</i> method.
-	 * @see LoggerAppender::doAppend()
+	 * Performs threshold checks and invokes filters before delegating logging 
+	 * to the subclass' specific <i>append()</i> method.
+	 * @see LoggerAppender::append()
 	 * @param LoggerLoggingEvent $event
 	 */
 	public function doAppend(LoggerLoggingEvent $event) {
@@ -135,8 +149,7 @@ abstract class LoggerAppender {
 	}	 
 
 	/**
-	 * Set the Layout for this appender.
-	 * @see LoggerAppender::setLayout()
+	 * Sets the appender layout.
 	 * @param LoggerLayout $layout
 	 */
 	public function setLayout($layout) {
@@ -146,8 +159,7 @@ abstract class LoggerAppender {
 	} 
 	
 	/**
-	 * Returns this appender layout.
-	 * @see LoggerAppender::getLayout()
+	 * Returns the appender layout.
 	 * @return LoggerLayout
 	 */
 	public function getLayout() {
@@ -169,7 +181,6 @@ abstract class LoggerAppender {
 	 * implementation admits a layout but can also work without it, then
 	 * the appender should return <i>true</i>.</p>
 	 * 
-	 * @see LoggerAppender::requiresLayout()
 	 * @return boolean
 	 */
 	public function requiresLayout() {
@@ -177,20 +188,15 @@ abstract class LoggerAppender {
 	}
 	
 	/**
-	 * Get the name of this appender.
-	 * @see LoggerAppender::getName()
+	 * Retruns the appender name.
 	 * @return string
 	 */
 	public function getName() {
 		return $this->name;
 	}
 	
-/**
-	 * Set the name of this appender.
-	 *
-	 * The name is used by other components to identify this appender.
-	 *
-	 * 
+	/**
+	 * Sets the appender name.
 	 * @param string $name
 	 */
 	public function setName($name) {
@@ -198,8 +204,7 @@ abstract class LoggerAppender {
 	}
 	
 	/**
-	 * Returns this appenders threshold level. 
-	 * See the {@link setThreshold()} method for the meaning of this option.
+	 * Returns the appender's threshold level. 
 	 * @return LoggerLevel
 	 */
 	public function getThreshold() { 
@@ -207,9 +212,10 @@ abstract class LoggerAppender {
 	}
 	
 	/**
-	 * Set the threshold level of this appender.
-	 *
-	 * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
+	 * Sets the appender threshold.
+	 * 
+	 * @param LoggerLevel|string $threshold Either a {@link LoggerLevel} 
+	 *   object or a string equivalent.
 	 * @see LoggerOptionConverter::toLevel()
 	 */
 	public function setThreshold($threshold) {
@@ -221,12 +227,13 @@ abstract class LoggerAppender {
 	}
 	
 	/**
-	 * Check whether the message level is below the appender's threshold. 
-	 *
+	 * Checks whether the message level is below the appender's threshold. 
 	 *
 	 * If there is no threshold set, then the return value is always <i>true</i>.
+	 * 
 	 * @param LoggerLevel $level
-	 * @return boolean true if priority is greater or equal than threshold	
+	 * @return boolean Returns true if level is greater or equal than 
+	 *   threshold, or if the threshold is not set. Otherwise returns false.
 	 */
 	public function isAsSevereAsThreshold($level) {
 		if($this->threshold === null) {
@@ -236,26 +243,32 @@ abstract class LoggerAppender {
 	}
 
 	/**
+	 * Prepares the appender for logging.
+	 * 
 	 * Derived appenders should override this method if option structure
 	 * requires it.
 	 */
-	abstract public function activateOptions();
+	public function activateOptions() {
+		$this->closed = false;
+	}
 	
 	/**
-	 * Subclasses of {@link LoggerAppender} should implement 
-	 * this method to perform actual logging.
-	 *
+	 * Forwards the logging event to the destination.
+	 * 
+	 * Derived appenders should implement this method to perform actual logging.
+	 * 
 	 * @param LoggerLoggingEvent $event
-	 * @see doAppend()
-	 * @abstract
 	 */
 	abstract protected function append(LoggerLoggingEvent $event); 
 
 	/**
-	 * Release any resources allocated.
-	 * Subclasses of {@link LoggerAppender} should implement 
-	 * this method to perform proper closing procedures.
-	 * @abstract
+	 * Releases any resources allocated by the appender.
+	 * 
+	 * Derived appenders should override this method to perform proper closing
+	 * procedures.
 	 */
-	abstract public function close();
+	public function close() {
+		$this->closed = true;
+	}
+	
 }

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderConsole.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderConsole.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderConsole.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderConsole.php Wed Sep  7 13:49:35
2011
@@ -58,10 +58,6 @@ class LoggerAppenderConsole extends Logg
 	 */
 	protected $fp = null;
 
-	public function __destruct() {
-		$this->close();
-	}
-	
 	/**
 	 * Set console target.
 	 * @param mixed $value a constant or a string
@@ -83,9 +79,6 @@ class LoggerAppenderConsole extends Logg
 		$this->closed = (bool)is_resource($this->fp) === false;
 	}
 	
-	/**
-	 * @see LoggerAppender::close()
-	 */
 	public function close() {
 		if($this->closed != true) {
 			if (is_resource($this->fp) && $this->layout !== null) {

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderDailyFile.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderDailyFile.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderDailyFile.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderDailyFile.php Wed Sep  7 13:49:35
2011
@@ -59,10 +59,6 @@ class LoggerAppenderDailyFile extends Lo
 	 */
 	public $datePattern = "Ymd";
 	
-	public function __destruct() {
-		parent::__destruct();
-	}
-	
 	/**
 	 * Sets date format for the file name.
 	 * @param string $datePattern a regular date() string format

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderEcho.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderEcho.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderEcho.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderEcho.php Wed Sep  7 13:49:35
2011
@@ -49,19 +49,6 @@ class LoggerAppenderEcho extends LoggerA
 	 * break in the logged message. Default value is false. @var boolean 
 	 */
 	private $htmlLineBreaks = false;
-
-	public function __construct($name = '') {
-		parent::__construct($name);
-		$this->firstAppend = true;
-	}
-	
-	public function __destruct() {
-		$this->close();
-	}
-
-	public function activateOptions() {
-		$this->closed = false;
-	}
 	
 	public function close() {
 		if($this->closed != true) {

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderFile.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderFile.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderFile.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderFile.php Wed Sep  7 13:49:35
2011
@@ -57,14 +57,6 @@ class LoggerAppenderFile extends LoggerA
 	 */
 	protected $fp = false;
 	
-	public function __construct($name = '') {
-		parent::__construct($name);
-	}
-
-	public function __destruct() {
-		$this->close();
-	}
-	
 	public function activateOptions() {
 		$fileName = $this->getFile();
 

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMail.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMail.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMail.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMail.php Wed Sep  7 13:49:35
2011
@@ -69,23 +69,6 @@ class LoggerAppenderMail extends LoggerA
 	/** @var string used to create mail body */
 	private $body = '';
 	
-	/**
-	 * Constructor.
-	 *
-	 * @param string $name appender name
-	 */
-	public function __construct($name = '') {
-		parent::__construct($name);
-	}
-
-	public function __destruct() {
-		$this->close();
-	}
-
-	public function activateOptions() {
-		$this->closed = false;
-	}
-	
 	public function close() {
 		if($this->closed != true) {
 			$from = $this->from;

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMailEvent.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMailEvent.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMailEvent.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMailEvent.php Wed Sep  7 13:49:35
2011
@@ -81,19 +81,6 @@ class LoggerAppenderMailEvent extends Lo
 	/** @var indiciates if this appender should run in dry mode */
 	private $dry = false;
 	
-	/**
-	 * Constructor.
-	 *
-	 * @param string $name appender name
-	 */
-	public function __construct($name = '') {
-		parent::__construct($name);
-	}
-
-	public function __destruct() {
-		$this->close();
-	}
-	
 	public function activateOptions() {
 		if (empty($this->layout)) {
 			throw new LoggerException("LoggerAppenderMailEvent requires layout!");
@@ -110,10 +97,6 @@ class LoggerAppenderMailEvent extends Lo
 		$this->closed = false;
 	}
 	
-	public function close() {
-		$this->closed = true;
-	}
-
 	public function setFrom($from) {
 		$this->from = $from;
 	}

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMongoDB.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMongoDB.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMongoDB.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderMongoDB.php Wed Sep  7 13:49:35
2011
@@ -216,10 +216,6 @@ class LoggerAppenderMongoDB extends Logg
 		}
 	}
 	
-	public function __destruct() {
-		$this->close();
-	}
-	
 	/** Sets the value of {@link $host} parameter. */
 	public function setHost($host) {
 		if (!preg_match('/^mongodb\:\/\//', $host)) {

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderNull.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderNull.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderNull.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderNull.php Wed Sep  7 13:49:35
2011
@@ -35,20 +35,11 @@
  */
 class LoggerAppenderNull extends LoggerAppender {
 
+	/** 
+	 * This appender does not require a layout. 
+	 */
 	protected $requiresLayout = false;
 	
-	public function __destruct() {
-		$this->close();
-	}
-	
-	public function activateOptions() {
-		$this->closed = false;
-	}
-	
-	public function close() {
-		$this->closed = true;
-	}
-	
 	/**
 	 * Do nothing. 
 	 * 

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPDO.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPDO.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPDO.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPDO.php Wed Sep  7 13:49:35
2011
@@ -119,19 +119,6 @@ class LoggerAppenderPDO extends LoggerAp
 	protected $requiresLayout = false;
 	
 	/**
-	 * Constructor.
-	 * This apender doesn't require a layout.
-	 * @param string $name appender name
-	 */
-	public function __construct($name = '') {
-		parent::__construct($name);
-	}
-	
-	public function __destruct() {
-	   $this->close();
-   	}
-   	
-	/**
 	 * Setup db connection.
 	 * Based on defined options, this method connects to db defined in {@link $dsn}
 	 * and creates a {@link $table} table if {@link $createTable} is true.

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPhp.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPhp.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPhp.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderPhp.php Wed Sep  7 13:49:35
2011
@@ -23,10 +23,11 @@
  *
  * This appender has no configurable parameters.
  *
- * <p>Levels are mapped as follows:</p>
- * - <b>level &lt; WARN</b> mapped to E_USER_NOTICE
- * - <b>WARN &lt;= level &lt; ERROR</b> mapped to E_USER_WARNING
- * - <b>level &gt;= ERROR</b> mapped to E_USER_ERROR  
+ * Levels are mapped as follows:
+ * 
+ * - <b>level < WARN</b> mapped to E_USER_NOTICE
+ * - <b>WARN <= level < ERROR</b> mapped to E_USER_WARNING
+ * - <b>level >= ERROR</b> mapped to E_USER_ERROR  
  *
  * An example:
  * 
@@ -40,22 +41,6 @@
  */ 
 class LoggerAppenderPhp extends LoggerAppender {
 
-	public function __construct($name = '') {
-		parent::__construct($name);
-	}
-	
-	public function __destruct() {
-		$this->close();
-	}
-	
-	public function activateOptions() {
-		$this->closed = false;
-	}
-
-	public function close() {
-		$this->closed = true;
-	}
-
 	public function append(LoggerLoggingEvent $event) {
 		if($this->layout !== null) {
 			$level = $event->getLevel();

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php Wed Sep  7
13:49:35 2011
@@ -85,10 +85,6 @@ class LoggerAppenderRollingFile extends 
 	 */
 	private $expandedFileName = null;
 
-	public function __destruct() {
-		parent::__destruct();
-	}
-	
 	/**
 	 * Returns the value of the MaxBackupIndex option.
 	 * @return integer 

Modified: logging/log4php/trunk/src/main/php/appenders/LoggerAppenderSocket.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/appenders/LoggerAppenderSocket.php?rev=1166182&r1=1166181&r2=1166182&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/appenders/LoggerAppenderSocket.php (original)
+++ logging/log4php/trunk/src/main/php/appenders/LoggerAppenderSocket.php Wed Sep  7 13:49:35
2011
@@ -97,10 +97,6 @@ class LoggerAppenderSocket extends Logge
 	/** @var indiciates if this appender should run in dry mode */
 	private $dry = false;
 	
-	public function __destruct() {
-		$this->close();
-	}
-	
 	/**
 	 * Create a socket connection using defined parameters
 	 */



Mime
View raw message