      1: <?php
      2: /**
      3:  * Licensed to the Apache Software Foundation (ASF) under one or more
      4:  * contributor license agreements. See the NOTICE file distributed with
      5:  * this work for additional information regarding copyright ownership.
      6:  * The ASF licenses this file to You under the Apache License, Version 2.0
      7:  * (the "License"); you may not use this file except in compliance with
      8:  * the License. You may obtain a copy of the License at
      9:  *
     10:  *      http://www.apache.org/licenses/LICENSE-2.0
     11:  *
     12:  * Unless required by applicable law or agreed to in writing, software
     13:  * distributed under the License is distributed on an "AS IS" BASIS,
     14:  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15:  * See the License for the specific language governing permissions and
     16:  * limitations under the License.
     17:  *
     18:  * @package log4php
     19:  */
     20:
     21: if (function_exists('__autoload')) {
     22:     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);
     23: }
     24:
     25: spl_autoload_register(array('LoggerAutoloader', 'autoload'));
     26:
     27: /**
     28:  * Class autoloader.
     29:  *
     30:  * @package log4php
     31:  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
     32:  * @version $Revision: 1394956 $
     33:  */
     34: class LoggerAutoloader {
     35:
     36:     /** Maps classnames to files containing the class. */
     37:     private static $classes = array(
     38:
     39:         // Base
     40:         'LoggerAppender' => '/LoggerAppender.php',
     41:         'LoggerAppenderPool' => '/LoggerAppenderPool.php',
     42:         'LoggerConfigurable' => '/LoggerConfigurable.php',
     43:         'LoggerConfigurator' => '/LoggerConfigurator.php',
     44:         'LoggerException' => '/LoggerException.php',
     45:         'LoggerFilter' => '/LoggerFilter.php',
     46:         'LoggerHierarchy' => '/LoggerHierarchy.php',
     47:         'LoggerLevel' => '/LoggerLevel.php',
     48:         'LoggerLocationInfo' => '/LoggerLocationInfo.php',
     49:         'LoggerLoggingEvent' => '/LoggerLoggingEvent.php',
     50:         'LoggerMDC' => '/LoggerMDC.php',
     51:         'LoggerNDC' => '/LoggerNDC.php',
     52:         'LoggerLayout' => '/LoggerLayout.php',
     53:         'LoggerReflectionUtils' => '/LoggerReflectionUtils.php',
     54:         'LoggerRoot' => '/LoggerRoot.php',
     55:         'LoggerThrowableInformation' => '/LoggerThrowableInformation.php',
     56:
     57:         // Appenders
     58:         'LoggerAppenderConsole' => '/appenders/LoggerAppenderConsole.php',
     59:         'LoggerAppenderDailyFile' => '/appenders/LoggerAppenderDailyFile.php',
     60:         'LoggerAppenderEcho' => '/appenders/LoggerAppenderEcho.php',
     61:         'LoggerAppenderFile' => '/appenders/LoggerAppenderFile.php',
     62:         'LoggerAppenderMail' => '/appenders/LoggerAppenderMail.php',
     63:         'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php',
     64:         'LoggerAppenderMongoDB' => '/appenders/LoggerAppenderMongoDB.php',
     65:         'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php',
     66:         'LoggerAppenderFirePHP' => '/appenders/LoggerAppenderFirePHP.php',
     67:         'LoggerAppenderPDO' => '/appenders/LoggerAppenderPDO.php',
     68:         'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php',
     69:         'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php',
     70:         'LoggerAppenderSocket' => '/appenders/LoggerAppenderSocket.php',
     71:         'LoggerAppenderSyslog' => '/appenders/LoggerAppenderSyslog.php',
     72:
     73:         // Configurators
     74:         'LoggerConfigurationAdapter' => '/configurators/LoggerConfigurationAdapter.php',
     75:         'LoggerConfigurationAdapterINI' => '/configurators/LoggerConfigurationAdapterINI.php',
     76:         'LoggerConfigurationAdapterPHP' => '/configurators/LoggerConfigurationAdapterPHP.php',
     77:         'LoggerConfigurationAdapterXML' => '/configurators/LoggerConfigurationAdapterXML.php',
     78:         'LoggerConfiguratorDefault' => '/configurators/LoggerConfiguratorDefault.php',
     79:
     80:         // Filters
     81:         'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php',
     82:         'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php',
     83:         'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php',
     84:         'LoggerFilterStringMatch' => '/filters/LoggerFilterStringMatch.php',
     85:
     86:         // Helpers
     87:         'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php',
     88:         'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php',
     89:         'LoggerPatternParser' => '/helpers/LoggerPatternParser.php',
     90:         'LoggerUtils' => '/helpers/LoggerUtils.php',
     91:
     92:         // Pattern converters
     93:         'LoggerPatternConverter' => '/pattern/LoggerPatternConverter.php',
     94:         'LoggerPatternConverterClass' => '/pattern/LoggerPatternConverterClass.php',
     95:         'LoggerPatternConverterCookie' => '/pattern/LoggerPatternConverterCookie.php',
     96:         'LoggerPatternConverterDate' => '/pattern/LoggerPatternConverterDate.php',
     97:         'LoggerPatternConverterEnvironment' => '/pattern/LoggerPatternConverterEnvironment.php',
     98:         'LoggerPatternConverterFile' => '/pattern/LoggerPatternConverterFile.php',
     99:         'LoggerPatternConverterLevel' => '/pattern/LoggerPatternConverterLevel.php',
    100:         'LoggerPatternConverterLine' => '/pattern/LoggerPatternConverterLine.php',
    101:         'LoggerPatternConverterLiteral' => '/pattern/LoggerPatternConverterLiteral.php',
    102:         'LoggerPatternConverterLocation' => '/pattern/LoggerPatternConverterLocation.php',
    103:         'LoggerPatternConverterLogger' => '/pattern/LoggerPatternConverterLogger.php',
    104:         'LoggerPatternConverterMDC' => '/pattern/LoggerPatternConverterMDC.php',
    105:         'LoggerPatternConverterMessage' => '/pattern/LoggerPatternConverterMessage.php',
    106:         'LoggerPatternConverterMethod' => '/pattern/LoggerPatternConverterMethod.php',
    107:         'LoggerPatternConverterNDC' => '/pattern/LoggerPatternConverterNDC.php',
    108:         'LoggerPatternConverterNewLine' => '/pattern/LoggerPatternConverterNewLine.php',
    109:         'LoggerPatternConverterProcess' => '/pattern/LoggerPatternConverterProcess.php',
    110:         'LoggerPatternConverterRelative' => '/pattern/LoggerPatternConverterRelative.php',
    111:         'LoggerPatternConverterRequest' => '/pattern/LoggerPatternConverterRequest.php',
    112:         'LoggerPatternConverterServer' => '/pattern/LoggerPatternConverterServer.php',
    113:         'LoggerPatternConverterSession' => '/pattern/LoggerPatternConverterSession.php',
    114:         'LoggerPatternConverterSessionID' => '/pattern/LoggerPatternConverterSessionID.php',
    115:         'LoggerPatternConverterSuperglobal' => '/pattern/LoggerPatternConverterSuperglobal.php',
    116:         'LoggerPatternConverterThrowable' => '/pattern/LoggerPatternConverterThrowable.php',
    117:
    118:         // Layouts
    119:         'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php',
    120:         'LoggerLayoutPattern' => '/layouts/LoggerLayoutPattern.php',
    121:         'LoggerLayoutSerialized' => '/layouts/LoggerLayoutSerialized.php',
    122:         'LoggerLayoutSimple' => '/layouts/LoggerLayoutSimple.php',
    123:         'LoggerLayoutTTCC' => '/layouts/LoggerLayoutTTCC.php',
    124:         'LoggerLayoutXml' => '/layouts/LoggerLayoutXml.php',
    125:
    126:         // Renderers
    127:         'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php',
    128:         'LoggerRendererException' => '/renderers/LoggerRendererException.php',
    129:         'LoggerRendererMap' => '/renderers/LoggerRendererMap.php',
    130:         'LoggerRenderer' => '/renderers/LoggerRenderer.php',
    131:     );
    132:
    133:     /**
    134:      * Loads a class.
    135:      * @param string $className The name of the class to load.
    136:      */
    137:     public static function autoload($className) {
    138:         if(isset(self::$classes[$className])) {
    139:             include dirname(__FILE__) . self::$classes[$className];
    140:         }
    141:     }
    142: }
    143: