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/08/27 23:19:21 UTC

svn commit: r808633 - in /incubator/log4php/trunk/src: changes/changes.xml main/php/configurators/LoggerConfiguratorXml.php test/php/configurators/LoggerConfiguratorXmlTest.php test/php/configurators/test1.xml

Author: grobmeier
Date: Thu Aug 27 21:19:20 2009
New Revision: 808633

URL: http://svn.apache.org/viewvc?rev=808633&view=rev
Log:
LoggerXmlConfigurator can now understand threshold attributes at appender level

Modified:
    incubator/log4php/trunk/src/changes/changes.xml
    incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php
    incubator/log4php/trunk/src/test/php/configurators/LoggerConfiguratorXmlTest.php
    incubator/log4php/trunk/src/test/php/configurators/test1.xml

Modified: incubator/log4php/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/changes/changes.xml?rev=808633&r1=808632&r2=808633&view=diff
==============================================================================
--- incubator/log4php/trunk/src/changes/changes.xml (original)
+++ incubator/log4php/trunk/src/changes/changes.xml Thu Aug 27 21:19:20 2009
@@ -73,6 +73,7 @@
 		<action type="fix" issue="LOG4PHP-71" by="Christian Grobmeier">Using LoggerAppenderFile logging to the log file in one Apache session blocks every other Apache session that tries to write to the file until the original request has been processed</action>
 		<action type="fix" issue="LOG4PHP-76" by="Dan Hansen">Unable to configure socket appender with attribute useXml = true</action>
 		<action type="fix" issue="LOG4PHP-77" by="Dan Hansen">LoggerReflectionUtils::setter() should be defined as a static method</action>
+		<action type="fix" by="Christian Grobmeier">LoggerXmlConfigurator can now interpret threshold commands at appender level</action>
 		<action type="update" by="Knut Urdalen">Initial port to PHP 5</action>
 		<action type="update" by="Knut Urdalen">Established new unit test suite</action>
 		<action type="update" by="Knut Urdalen">Added a range of examples</action>

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=808633&r1=808632&r2=808633&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php (original)
+++ incubator/log4php/trunk/src/main/php/configurators/LoggerConfiguratorXml.php Thu Aug 27 21:19:20 2009
@@ -219,6 +219,13 @@
                 $class = $this->subst(@$attribs['CLASS']);
                 
                 $this->appender = LoggerAppenderPool::getAppenderFromPool($name, $class);
+                
+                if (isset($attribs['THRESHOLD'])) {
+                    $this->appender->setThreshold(
+                        LoggerOptionConverter::toLevel(
+                            $this->subst($attribs['THRESHOLD']), $this->appender->getThreshold()));
+                }
+                
                 $this->state[] = self::APPENDER_STATE;
                 break;
                 

Modified: incubator/log4php/trunk/src/test/php/configurators/LoggerConfiguratorXmlTest.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/test/php/configurators/LoggerConfiguratorXmlTest.php?rev=808633&r1=808632&r2=808633&view=diff
==============================================================================
--- incubator/log4php/trunk/src/test/php/configurators/LoggerConfiguratorXmlTest.php (original)
+++ incubator/log4php/trunk/src/test/php/configurators/LoggerConfiguratorXmlTest.php Thu Aug 27 21:19:20 2009
@@ -45,4 +45,32 @@
 		$logger = Logger::getLogger('mylogger');
 		self::assertEquals(LoggerLevel::getLevelInfo(), $logger->getLevel());
 	}
+	
+	public function testThreshold() {
+		Logger::configure('configurators/test1.xml');
+		$root = Logger::getRootLogger();
+		self::assertEquals(LoggerLevel::getLevelWarn(), $root->getLevel());
+		$appender = $root->getAppender("default");
+		self::assertTrue($appender instanceof LoggerAppenderEcho);
+		$layout = $appender->getLayout();
+		self::assertTrue($layout instanceof LoggerLayoutSimple);
+		$threshold = $appender->getThreshold();
+		self::assertTrue($threshold instanceof LoggerLevel);
+		$e = LoggerLevel::getLevelWarn();
+		self::assertEquals($e,$threshold);
+		
+		$appender = $root->getAppender("blub");
+		self::assertTrue($appender instanceof LoggerAppenderEcho);
+		$layout = $appender->getLayout();
+		self::assertTrue($layout instanceof LoggerLayoutSimple);
+		$threshold = $appender->getThreshold();
+		self::assertTrue($threshold instanceof LoggerLevel);
+		$e = LoggerLevel::getLevelInfo();
+		self::assertEquals($e,$threshold);
+		
+		$threshold = Logger::getHierarchy()->getThreshold();
+		self::assertTrue($threshold instanceof LoggerLevel);
+		$e = LoggerLevel::getLevelWarn();
+		self::assertEquals($e,$threshold);
+	}
 }

Modified: incubator/log4php/trunk/src/test/php/configurators/test1.xml
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/test/php/configurators/test1.xml?rev=808633&r1=808632&r2=808633&view=diff
==============================================================================
--- incubator/log4php/trunk/src/test/php/configurators/test1.xml (original)
+++ incubator/log4php/trunk/src/test/php/configurators/test1.xml Thu Aug 27 21:19:20 2009
@@ -16,16 +16,19 @@
  limitations under the License.
 
 -->
-<log4php:configuration
-  xmlns:log4php="http://logging.apache.org/log4php/">
-    <appender name="default" class="LoggerAppenderEcho">
+<log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="WARN">
+    <appender threshold="WARN" name="default" class="LoggerAppenderEcho">
+        <layout class="LoggerLayoutSimple"/>
+    </appender>
+    <appender threshold="INFO" name="blub" class="LoggerAppenderEcho">
         <layout class="LoggerLayoutSimple"/>
     </appender>
     <logger name="mylogger">
         <level value="info"/> 
     </logger>
     <root>
-         <level value="WARN" />
+        <level value="WARN" />
         <appender_ref ref="default" />
+        <appender_ref ref="blub" />
     </root>
 </log4php:configuration>