logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject svn commit: r1343630 - in /logging/log4php/trunk/src: changes/changes.xml main/php/LoggerMDC.php site/xdoc/changelog.xml test/php/LoggerMDCTest.php
Date Tue, 29 May 2012 09:46:39 GMT
Author: ihabunek
Date: Tue May 29 09:46:39 2012
New Revision: 1343630

URL: http://svn.apache.org/viewvc?rev=1343630&view=rev
Log:
LOG4PHP-180: Removed $_ENV and $_SERVER access from LoggerMDC

Modified:
    logging/log4php/trunk/src/changes/changes.xml
    logging/log4php/trunk/src/main/php/LoggerMDC.php
    logging/log4php/trunk/src/site/xdoc/changelog.xml
    logging/log4php/trunk/src/test/php/LoggerMDCTest.php

Modified: logging/log4php/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/changes/changes.xml?rev=1343630&r1=1343629&r2=1343630&view=diff
==============================================================================
--- logging/log4php/trunk/src/changes/changes.xml (original)
+++ logging/log4php/trunk/src/changes/changes.xml Tue May 29 09:46:39 2012
@@ -21,6 +21,7 @@
 	</properties>
 	<body>
 		<release version="2.3.0" date="SVN">
+			<action date="2011-05-29" type="update" dev="Ivan Habunek">Removed $_ENV and $_SERVER
access from LoggerMDC.</action>
 		    <action date="2011-03-19" type="update" dev="Ivan Habunek">Made LoggerLayoutTTCC
deprecated.</action>
 			<action date="2011-02-28" type="fix" issue="LOG4PHP-163" dev="Ivan Habunek">Fixed
formatting bug in LoggerLayoutPattern.</action>
 			<action date="2011-02-28" type="update" issue="LOG4PHP-172" dev="Ivan Habunek">Rewritten
pattern system to allow longer conversion words and some new ones.</action>

Modified: logging/log4php/trunk/src/main/php/LoggerMDC.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/LoggerMDC.php?rev=1343630&r1=1343629&r2=1343630&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/LoggerMDC.php (original)
+++ logging/log4php/trunk/src/main/php/LoggerMDC.php Tue May 29 09:46:39 2012
@@ -19,30 +19,16 @@
  */
 
 /**
- * The LoggerMDC class provides <i>mapped diagnostic contexts</i>.
+ * The LoggerMDC class provides _mapped diagnostic contexts_.
  * 
- * A <i>Mapped Diagnostic Context</i>, or
- * MDC in short, is an instrument for distinguishing interleaved log
- * output from different sources. Log output is typically interleaved
- * when a server handles multiple clients near-simultaneously.
+ * A Mapped Diagnostic Context, or MDC in short, is an instrument for 
+ * distinguishing interleaved log output from different sources. Log output 
+ * is typically interleaved when a server handles multiple clients 
+ * near-simultaneously.
  * 
  * This class is similar to the {@link LoggerNDC} class except that 
  * it is based on a map instead of a stack.
  * 
- * Example:
- * 
- * {@example ../../examples/php/mdc.php 19}<br>
- *
- * With the properties file:
- * 
- * {@example ../../examples/resources/mdc.properties 18}<br>
- * 
- * Will result in the following (notice the username "knut" in the output):
- * 
- * <pre>
- * 2009-09-13 18:48:28 DEBUG root knut: Testing MDC in src/examples/php/mdc.php at 23
- * </pre>
- * 
  * @version $Revision$
  * @since 0.3
  * @package log4php
@@ -66,28 +52,12 @@ class LoggerMDC {
 	/**
 	 * Returns the context value identified by the key parameter.
 	 *
-	 * Special key identifiers can be used to map values in the global $_SERVER
-	 * and $_ENV vars. To access them, use 'server.' or 'env.' followed by the 
-	 * desired var name as the key.
-	 *
 	 * @param string $key The key.
 	 * @return string The context or an empty string if no context found
 	 * 	for given key.
 	 */
 	public static function get($key) {
-		if(!empty($key)) {
-			if(strpos($key, 'server.') === 0) {
-				$varName = substr($key, 7);
-				return isset($_SERVER[$varName]) ? $_SERVER[$varName] : '';
-			} else if(strpos($key, 'env.') === 0) {
-				$varName = substr($key, 4);
-				$value = getenv($varName);
-				return ($value !== false) ? $value : '';
-			} else {
-				return isset(self::$map[$key]) ? self::$map[$key] : '';
-			}
-		}
-		return '';
+		return isset(self::$map[$key]) ? self::$map[$key] : '';
 	}
 
 	/**

Modified: logging/log4php/trunk/src/site/xdoc/changelog.xml
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/site/xdoc/changelog.xml?rev=1343630&r1=1343629&r2=1343630&view=diff
==============================================================================
--- logging/log4php/trunk/src/site/xdoc/changelog.xml (original)
+++ logging/log4php/trunk/src/site/xdoc/changelog.xml Tue May 29 09:46:39 2012
@@ -35,15 +35,15 @@
 				
 				<p><strong>New features:</strong></p>
 				<ul>
-					<li>New appender: <a href="docs/appenders/fire-php.html">FirePHP</a>
(thanks to Bruce Ingalls)</li>
+					<li>New appender: <a href="docs/appenders/firephp.html">FirePHP</a>
(thanks to Bruce Ingalls)</li>
 				</ul>
 				
 				<p><strong>Improvements:</strong></p>
 				<ul>
 					<li>The <a href="docs/layouts/pattern.html">pattern layout</a> has
been greatly improved:
 						<ul>
-							<li>supports longer conversion words such as <em>%date</em> instead
of <em>%d</em>, 
-								<em>%message</em> instead of <em>%m</em>, etc.</li>
+							<li>supports longer conversion words such as <code>%date</code>
instead of <code>%d</code>, 
+								<code>%message</code> instead of <code>%m</code>, etc.</li>
 							<li>added many new conversion words; check out the docs for the full list</li>
 						</ul>
 					</li>
@@ -51,13 +51,17 @@
 				
 				<p><strong>Breaking changes:</strong></p>
 				<ul>
-					<li>Several changes to <a href="docs/appenders/pdo.html">LoggerAppenderPDO</a>:
+					<li>Several changes to the <a href="docs/appenders/pdo.html">PDO appender</a>:
 						<ul>
 							<li>a database table for logging will no longer be created by the appender;
the user must 
 								create this table manually.</li>
 							<li>the default date pattern does not include milliseconds (this is faster)</li>
 						</ul>
 					</li>
+					<li>In the <a href="docs/layouts/pattern.html">pattern layout</a>,
it is no longer possible to 
+						access $_SERVER and $_ENV values using <code>%X{server.*}</code> and <code>%X{env.*}</code>
+						conversion words; use the new words <code>%server{*}</code> and <code>%env{*}</code>
instead.
+						</li>
 				</ul>
 				<p>Please review the documentation and make any necessary changes to your configuration.</p>
 				

Modified: logging/log4php/trunk/src/test/php/LoggerMDCTest.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/LoggerMDCTest.php?rev=1343630&r1=1343629&r2=1343630&view=diff
==============================================================================
--- logging/log4php/trunk/src/test/php/LoggerMDCTest.php (original)
+++ logging/log4php/trunk/src/test/php/LoggerMDCTest.php Tue May 29 09:46:39 2012
@@ -43,15 +43,6 @@ class LoggerMDCTest extends PHPUnit_Fram
 	/** A pattern without a key. */
 	private $pattern5 = "%-5p %c: %X %m";
 	
-	/** A pattern for testing values from $_ENV. */
-	private $patternEnv = "%-5p %c: %X{env.TEST} %m";
-	
-	/**
-	 * A pattern for testing values from $_SERVER. PHP_SELF chosen because it
-	 * appears on both Linux and Windows systems. 
-	 */
-	private $patternServer = "%-5p %c: %X{server.PHP_SELF} %m";
-	
 	protected function setUp() {
 		LoggerMDC::clear();
 	}
@@ -114,48 +105,6 @@ class LoggerMDCTest extends PHPUnit_Fram
 		self::assertEquals($expected, $actual);
     }
     
-    public function testEnvKey() {
-    	
-    	// Set an environment variable for testing
-    	if (putenv('TEST=abc') === false) {
-    		self::markTestSkipped("Unable to set environment variable for testing.");
-    	}
-    	
-    	// Test reading of the set variable
-    	self::assertEquals('abc', LoggerMDC::get('env.TEST'));
-    	
-    	// Test env variable in a pattern
-    	$event = LoggerTestHelper::getInfoEvent("Test message");
-    	$actual = $this->formatEvent($event, $this->patternEnv);
-		$expected = "INFO  test: abc Test message";
-		self::assertEquals($expected, $actual);
-		
-		// Test reading a non-existant env variable
-		self::assertEquals('', LoggerMDC::get('env.hopefully_this_variable_doesnt_exist'));
-		
-		// Test reading an empty env variable
-		self::assertEquals('', LoggerMDC::get('env.'));
-    }
-    
-    public function testServerKey() {
-    	
-    	// Test reading a server variable
-    	$value = $_SERVER['PHP_SELF'];
-    	self::assertEquals($value, LoggerMDC::get('server.PHP_SELF'));
-    	
-		// Test the server variable in a pattern
-    	$event = LoggerTestHelper::getInfoEvent("Test message");
-    	$actual = $this->formatEvent($event, $this->patternServer);
-		$expected = "INFO  test: $value Test message";
-		self::assertEquals($expected, $actual);
-		
-		// Test reading a non-existant server variable
-		self::assertEquals('', LoggerMDC::get('server.hopefully_this_variable_doesnt_exist'));
-		
-		// Test reading an empty server variable
-		self::assertEquals('', LoggerMDC::get('server.'));
-    }
-    
 	private function formatEvent($event, $pattern) {
 		$layout = new LoggerLayoutPattern();
 		$layout->setConversionPattern($pattern);



Mime
View raw message