Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A6E86D215 for ; Sat, 18 Aug 2012 16:01:15 +0000 (UTC) Received: (qmail 35945 invoked by uid 500); 18 Aug 2012 16:01:15 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 35921 invoked by uid 500); 18 Aug 2012 16:01:15 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 35911 invoked by uid 99); 18 Aug 2012 16:01:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Aug 2012 16:01:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Aug 2012 16:01:14 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1AA732388A5B; Sat, 18 Aug 2012 16:00:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1374601 - in /logging/log4php/trunk/src: main/php/configurators/LoggerConfigurationAdapterXML.php test/php/configurators/LoggerConfigurationAdapterXMLTest.php Date: Sat, 18 Aug 2012 16:00:30 -0000 To: commits@logging.apache.org From: ihabunek@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120818160031.1AA732388A5B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ihabunek Date: Sat Aug 18 16:00:30 2012 New Revision: 1374601 URL: http://svn.apache.org/viewvc?rev=1374601&view=rev Log: LoggerConfigurationAdapterXML: Added parsing of nodes, as well as in loggers for backward compatibility. Modified: logging/log4php/trunk/src/main/php/configurators/LoggerConfigurationAdapterXML.php logging/log4php/trunk/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php Modified: logging/log4php/trunk/src/main/php/configurators/LoggerConfigurationAdapterXML.php URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/configurators/LoggerConfigurationAdapterXML.php?rev=1374601&r1=1374600&r2=1374601&view=diff ============================================================================== --- logging/log4php/trunk/src/main/php/configurators/LoggerConfigurationAdapterXML.php (original) +++ logging/log4php/trunk/src/main/php/configurators/LoggerConfigurationAdapterXML.php Sat Aug 18 16:00:30 2012 @@ -173,10 +173,7 @@ class LoggerConfigurationAdapterXML impl $logger['level'] = $this->getAttributeValue($node->level, 'value'); } - $logger['appenders'] = array(); - foreach($node->appender_ref as $appender) { - $logger['appenders'][] = $this->getAttributeValue($appender, 'ref'); - } + $logger['appenders'] = $this->parseAppenderReferences($node); $this->config['rootLogger'] = $logger; } @@ -199,7 +196,7 @@ class LoggerConfigurationAdapterXML impl $logger['additivity'] = $this->getAttributeValue($node, 'additivity'); } - $logger['appenders'] = $this->parseAppenderReferences($node, $name); + $logger['appenders'] = $this->parseAppenderReferences($node); // Check for duplicate loggers if (isset($this->config['loggers'][$name])) { @@ -211,13 +208,20 @@ class LoggerConfigurationAdapterXML impl /** * Parses a node for appender references and returns them in an array. + * + * Previous versions supported appender-ref, as well as appender_ref so both + * are parsed for backward compatibility. */ - private function parseAppenderReferences(SimpleXMLElement $node, $name) { + private function parseAppenderReferences(SimpleXMLElement $node) { $refs = array(); foreach($node->appender_ref as $ref) { $refs[] = $this->getAttributeValue($ref, 'ref'); } + foreach($node->{'appender-ref'} as $ref) { + $refs[] = $this->getAttributeValue($ref, 'ref'); + } + return $refs; } Modified: logging/log4php/trunk/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php?rev=1374601&r1=1374600&r2=1374601&view=diff ============================================================================== --- logging/log4php/trunk/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php (original) +++ logging/log4php/trunk/src/test/php/configurators/LoggerConfigurationAdapterXMLTest.php Sat Aug 18 16:00:30 2012 @@ -114,6 +114,14 @@ class LoggerConfigurationAdapterXMLTest $this->assertEquals($this->expected1, $actual); } + public function testConversion2() { + $url = PHPUNIT_CONFIG_DIR . '/adapters/xml/config_valid_underscore.xml'; + $adapter = new LoggerConfigurationAdapterXML(); + $actual = $adapter->convert($url); + + $this->assertEquals($this->expected1, $actual); + } + /** * Test exception is thrown when file cannot be found. * @expectedException LoggerException