logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject svn commit: r1226679 - in /logging/log4php/trunk/src/main/php: Logger.php LoggerAutoloader.php
Date Tue, 03 Jan 2012 07:39:23 GMT
Author: ihabunek
Date: Tue Jan  3 07:39:23 2012
New Revision: 1226679

URL: http://svn.apache.org/viewvc?rev=1226679&view=rev
Log:
Moved autoloader functionality to a separate file and class.

Added:
    logging/log4php/trunk/src/main/php/LoggerAutoloader.php
Modified:
    logging/log4php/trunk/src/main/php/Logger.php

Modified: logging/log4php/trunk/src/main/php/Logger.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/Logger.php?rev=1226679&r1=1226678&r2=1226679&view=diff
==============================================================================
--- logging/log4php/trunk/src/main/php/Logger.php (original)
+++ logging/log4php/trunk/src/main/php/Logger.php Tue Jan  3 07:39:23 2012
@@ -18,11 +18,7 @@
  * @package log4php
  */
 
-if (function_exists('__autoload')) {
-	trigger_error("log4php: It looks like your code is using an __autoload() function. log4php
uses spl_autoload_register() which will bypass your __autoload() function and may break autoloading.",
E_USER_WARNING);
-}
-
-spl_autoload_register(array('Logger', 'autoload'));
+require dirname(__FILE__) . '/LoggerAutoloader.php';
 
 /**
  * This is the central class in the log4php package. All logging operations 
@@ -44,88 +40,7 @@ spl_autoload_register(array('Logger', 'a
  * @link	   http://logging.apache.org/log4php
  */
 class Logger {
-	private static $_classes = array(
-		'LoggerException' => '/LoggerException.php',
-		'LoggerHierarchy' => '/LoggerHierarchy.php',
-		'LoggerLayout' => '/LoggerLayout.php',
-		'LoggerLevel' => '/LoggerLevel.php',
-		'LoggerMDC' => '/LoggerMDC.php',
-		'LoggerNDC' => '/LoggerNDC.php',
-		'LoggerReflectionUtils' => '/LoggerReflectionUtils.php',
-		'LoggerConfigurable' => '/LoggerConfigurable.php',
-		'LoggerConfigurator' => '/LoggerConfigurator.php',
-		'LoggerConfiguratorDefault' => '/configurators/LoggerConfiguratorDefault.php',
-		'LoggerConfigurationAdapter' => '/configurators/LoggerConfigurationAdapter.php',
-		'LoggerConfigurationAdapterINI' => '/configurators/LoggerConfigurationAdapterINI.php',
-		'LoggerConfigurationAdapterXML' => '/configurators/LoggerConfigurationAdapterXML.php',
-		'LoggerConfigurationAdapterPHP' => '/configurators/LoggerConfigurationAdapterPHP.php',
-		'LoggerRoot' => '/LoggerRoot.php',
-		'LoggerAppender' => '/LoggerAppender.php',
-		'LoggerAppenderPool' => '/LoggerAppenderPool.php',
-		'LoggerAppenderPDO' => '/appenders/LoggerAppenderPDO.php',
-		'LoggerAppenderConsole' => '/appenders/LoggerAppenderConsole.php',
-		'LoggerAppenderDailyFile' => '/appenders/LoggerAppenderDailyFile.php',
-		'LoggerAppenderEcho' => '/appenders/LoggerAppenderEcho.php',
-		'LoggerAppenderFile' => '/appenders/LoggerAppenderFile.php',
-		'LoggerAppenderMail' => '/appenders/LoggerAppenderMail.php',
-		'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php',
-		'LoggerAppenderMongoDB' => '/appenders/LoggerAppenderMongoDB.php',
-		'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php',
-		'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php',
-		'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php',
-		'LoggerAppenderSocket' => '/appenders/LoggerAppenderSocket.php',
-		'LoggerAppenderSyslog' => '/appenders/LoggerAppenderSyslog.php',
-		'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php',
-		'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php',
-		'LoggerPatternConverter' => '/helpers/LoggerPatternConverter.php',
-		'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php',
-		'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php',
-		'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php',
-		'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php',
-		'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php',
-		'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php',
-		'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php',
-		'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php',
-		'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php',
-		'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php',
-		'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php',
-		'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php',
-		'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php',
-		'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php',
-		'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php',
-		'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php',
-		'LoggerPatternParser' => '/helpers/LoggerPatternParser.php',
-		'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php',
-		'LoggerLayoutSimple' => '/layouts/LoggerLayoutSimple.php',
-		'LoggerLayoutTTCC' => '/layouts/LoggerLayoutTTCC.php',
-		'LoggerLayoutPattern' => '/layouts/LoggerLayoutPattern.php',
-		'LoggerLayoutSerialized' => '/layouts/LoggerLayoutSerialized.php',
-		'LoggerLayoutXml' => '/layouts/LoggerLayoutXml.php',
-		'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php',
-		'LoggerRendererObject' => '/renderers/LoggerRendererObject.php',
-		'LoggerRendererMap' => '/renderers/LoggerRendererMap.php',
-		'LoggerRendererException' => '/renderers/LoggerRendererException.php',
-		'LoggerLocationInfo' => '/LoggerLocationInfo.php',
-		'LoggerThrowableInformation' => '/LoggerThrowableInformation.php',
-		'LoggerLoggingEvent' => '/LoggerLoggingEvent.php',
-		'LoggerFilter' => '/LoggerFilter.php',
-		'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php',
-		'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php',
-		'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php',
-		'LoggerFilterStringMatch' => '/filters/LoggerFilterStringMatch.php'
-	);
-
-	/**
-	 * Class autoloader. This method is provided to be invoked within an 
-	 * __autoload() magic method.
-	 * @param string $className The name of the class to load.
-	 */
-	public static function autoload($className) {
-		if(isset(self::$_classes[$className])) {
-			include dirname(__FILE__) . self::$_classes[$className];
-		}
-	}
-
+	
 	/**
 	 * Logger additivity. If set to true then child loggers will inherit
 	 * the appenders of their ancestors by default.

Added: logging/log4php/trunk/src/main/php/LoggerAutoloader.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/LoggerAutoloader.php?rev=1226679&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/LoggerAutoloader.php (added)
+++ logging/log4php/trunk/src/main/php/LoggerAutoloader.php Tue Jan  3 07:39:23 2012
@@ -0,0 +1,125 @@
+<?php
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ *		http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * @package log4php
+ */
+
+if (function_exists('__autoload')) {
+	trigger_error("log4php: It looks like your code is using an __autoload() function. log4php
uses spl_autoload_register() which will bypass your __autoload() function and may break autoloading.",
E_USER_WARNING);
+}
+
+spl_autoload_register(array('LoggerAutoloader', 'autoload'));
+
+/**
+ * Class autoloader.
+ * 
+ * @package log4php
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @version $Revision$
+ */
+class LoggerAutoloader {
+	
+	/** Maps classnames to files containing the class. */
+	private static $classes = array(
+	
+		// Base
+		'LoggerAppender' => '/LoggerAppender.php',
+		'LoggerAppenderPool' => '/LoggerAppenderPool.php',
+		'LoggerConfigurable' => '/LoggerConfigurable.php',
+		'LoggerConfigurator' => '/LoggerConfigurator.php',
+		'LoggerException' => '/LoggerException.php',
+		'LoggerHierarchy' => '/LoggerHierarchy.php',
+		'LoggerLevel' => '/LoggerLevel.php',
+		'LoggerLocationInfo' => '/LoggerLocationInfo.php',
+		'LoggerLoggingEvent' => '/LoggerLoggingEvent.php',
+		'LoggerMDC' => '/LoggerMDC.php',
+		'LoggerNDC' => '/LoggerNDC.php',
+		'LoggerLayout' => '/LoggerLayout.php',
+		'LoggerReflectionUtils' => '/LoggerReflectionUtils.php',
+		'LoggerRoot' => '/LoggerRoot.php',
+		'LoggerThrowableInformation' => '/LoggerThrowableInformation.php',
+
+		// Appenders
+		'LoggerAppenderConsole' => '/appenders/LoggerAppenderConsole.php',
+		'LoggerAppenderDailyFile' => '/appenders/LoggerAppenderDailyFile.php',
+		'LoggerAppenderEcho' => '/appenders/LoggerAppenderEcho.php',
+		'LoggerAppenderFile' => '/appenders/LoggerAppenderFile.php',
+		'LoggerAppenderMail' => '/appenders/LoggerAppenderMail.php',
+		'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php',
+		'LoggerAppenderMongoDB' => '/appenders/LoggerAppenderMongoDB.php',
+		'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php',
+		'LoggerAppenderPDO' => '/appenders/LoggerAppenderPDO.php',
+		'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php',
+		'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php',
+		'LoggerAppenderSocket' => '/appenders/LoggerAppenderSocket.php',
+		'LoggerAppenderSyslog' => '/appenders/LoggerAppenderSyslog.php',
+		
+		// Configurators
+		'LoggerConfigurationAdapter' => '/configurators/LoggerConfigurationAdapter.php',
+		'LoggerConfigurationAdapterINI' => '/configurators/LoggerConfigurationAdapterINI.php',
+		'LoggerConfigurationAdapterPHP' => '/configurators/LoggerConfigurationAdapterPHP.php',
+		'LoggerConfigurationAdapterXML' => '/configurators/LoggerConfigurationAdapterXML.php',
+		'LoggerConfiguratorDefault' => '/configurators/LoggerConfiguratorDefault.php',
+
+		// Filters
+		'LoggerFilter' => '/LoggerFilter.php',
+		'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php',
+		'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php',
+		'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php',
+		'LoggerFilterStringMatch' => '/filters/LoggerFilterStringMatch.php',
+
+		// Helpers
+		'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php',
+		'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php',
+		'LoggerPatternParser' => '/helpers/LoggerPatternParser.php',
+		
+		// Converters
+		'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php',
+		'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php',
+		'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php',
+		'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php',
+		'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php',
+		'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php',
+		'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php',
+		'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php',
+		'LoggerPatternConverter' => '/helpers/LoggerPatternConverter.php',
+
+		// Layouts
+		'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php',
+		'LoggerLayoutPattern' => '/layouts/LoggerLayoutPattern.php',
+		'LoggerLayoutSerialized' => '/layouts/LoggerLayoutSerialized.php',
+		'LoggerLayoutSimple' => '/layouts/LoggerLayoutSimple.php',
+		'LoggerLayoutTTCC' => '/layouts/LoggerLayoutTTCC.php',
+		'LoggerLayoutXml' => '/layouts/LoggerLayoutXml.php',
+		
+		// Renderers
+		'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php',
+		'LoggerRendererException' => '/renderers/LoggerRendererException.php',
+		'LoggerRendererMap' => '/renderers/LoggerRendererMap.php',
+		'LoggerRendererObject' => '/renderers/LoggerRendererObject.php',
+	);
+
+	/**
+	 * Loads a class.
+	 * @param string $className The name of the class to load.
+	 */
+	public static function autoload($className) {
+		if(isset(self::$classes[$className])) {
+			include dirname(__FILE__) . self::$classes[$className];
+		}
+	}
+}



Mime
View raw message