logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject svn commit: r1210109 - in /logging/log4php/trunk/src: changes/changes.xml main/php/LoggerAppender.php test/php/LoggerAppenderTest.php
Date Sun, 04 Dec 2011 13:26:47 GMT
Author: ihabunek
Date: Sun Dec  4 13:26:46 2011
New Revision: 1210109

URL: http://svn.apache.org/viewvc?rev=1210109&view=rev
Log: (empty)

Modified:
    logging/log4php/trunk/src/changes/changes.xml
    logging/log4php/trunk/src/main/php/LoggerAppender.php
    logging/log4php/trunk/src/test/php/LoggerAppenderTest.php

Modified: logging/log4php/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/changes/changes.xml?rev=1210109&r1=1210108&r2=1210109&view=diff
==============================================================================
--- logging/log4php/trunk/src/changes/changes.xml (original)
+++ logging/log4php/trunk/src/changes/changes.xml Sun Dec  4 13:26:46 2011
@@ -21,6 +21,7 @@
 	</properties>
 	<body>
 	    <release version="2.2.0" date="SVN">
+	    	<action date="2011-12-04" type="add" issue="LOG4PHP-160" dev="Ivan Habunek" due-to="Florian
Semm" due-to-email="florian dot semm at gmx dot de">Appeneders should use a default layout
is no layout is specified in configuration</action>
 	    	<action date="2011-10-23" type="add" issue="LOG4PHP-155" dev="Ivan Habunek">Created
a new layout LoggerLayoutSerialized which formats events as serialized objects.</action>
 	    	<action date="2011-10-23" type="fix" issue="LOG4PHP-159" dev="Ivan Habunek" due-to="Justin
Cherniak" due-to-email="justin dot cherniak at gmail dot com">Appenders do not close gracefully
if a fatal error occurs.</action>
 	    	<action date="2011-10-15" type="update" issue="LOG4PHP-152" dev="Ivan Habunek">A
rewrite of the configurator.</action>

Modified: logging/log4php/trunk/src/main/php/LoggerAppender.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/LoggerAppender.php?rev=1210109&r1=1210108&r2=1210109&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/LoggerAppender.php (original)
+++ logging/log4php/trunk/src/main/php/LoggerAppender.php Sun Dec  4 13:26:46 2011
@@ -79,8 +79,23 @@ abstract class LoggerAppender {
 		// Closes the appender on shutdown. Better than a destructor because
 		// it will be called even if a fatal error occurs (destructor won't).
 		register_shutdown_function(array($this, 'close'));
+		
+		if ($this->requiresLayout) {
+			$this->layout = $this->getDefaultLayout();
+		}
 	}
-
+	
+	/**
+	 * Returns the default layout for this appender. Can be overriden by 
+	 * derived appenders.
+	 * 
+	 * @return LoggerLayout
+	 */
+	public function getDefaultLayout()
+	{
+		return new LoggerLayoutSimple();
+	}
+	
 	/**
 	 * Adds a filter to the end of the filter chain.
 	 * @param LoggerFilter $filter add a new LoggerFilter

Modified: logging/log4php/trunk/src/test/php/LoggerAppenderTest.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/LoggerAppenderTest.php?rev=1210109&r1=1210108&r2=1210109&view=diff
==============================================================================
--- logging/log4php/trunk/src/test/php/LoggerAppenderTest.php (original)
+++ logging/log4php/trunk/src/test/php/LoggerAppenderTest.php Sun Dec  4 13:26:46 2011
@@ -146,4 +146,28 @@ class LoggerAppenderTest extends PHPUnit
 		$nullfilter = $appender->getFilter();
 		self::assertNull($nullfilter);
     }
+    
+    public function testInstanciateWithLayout() {
+    	$appender = new LoggerAppenderEcho("LoggerAppenderTest");
+    	
+    	$expected = "LoggerLayoutSimple";
+    	$actual = $appender->getLayout();
+    	$this->assertInstanceof($expected, $actual);
+    }
+    
+    public function testOverwriteLayout() {
+    	$layout = new LoggerLayoutSimple();
+    	$appender = new LoggerAppenderEcho("LoggerAppenderTest");
+    	$appender->setLayout($layout);    	
+    	
+    	$actual = $appender->getLayout();
+    	$this->assertEquals($layout, $actual);
+    }
+
+    public function testRequiresNoLayout() {
+    	$appender = new LoggerAppenderNull("LoggerAppenderTest");
+		
+    	$actual = $appender->getLayout();
+    	$this->assertNull($actual);
+    }    
 }



Mime
View raw message