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$
|
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
|
'LoggerHierarchy' => '/LoggerHierarchy.php',
|
46
|
'LoggerLevel' => '/LoggerLevel.php',
|
47
|
'LoggerLocationInfo' => '/LoggerLocationInfo.php',
|
48
|
'LoggerLoggingEvent' => '/LoggerLoggingEvent.php',
|
49
|
'LoggerMDC' => '/LoggerMDC.php',
|
50
|
'LoggerNDC' => '/LoggerNDC.php',
|
51
|
'LoggerLayout' => '/LoggerLayout.php',
|
52
|
'LoggerReflectionUtils' => '/LoggerReflectionUtils.php',
|
53
|
'LoggerRoot' => '/LoggerRoot.php',
|
54
|
'LoggerThrowableInformation' => '/LoggerThrowableInformation.php',
|
55
|
|
56
|
// Appenders
|
57
|
'LoggerAppenderConsole' => '/appenders/LoggerAppenderConsole.php',
|
58
|
'LoggerAppenderDailyFile' => '/appenders/LoggerAppenderDailyFile.php',
|
59
|
'LoggerAppenderEcho' => '/appenders/LoggerAppenderEcho.php',
|
60
|
'LoggerAppenderFile' => '/appenders/LoggerAppenderFile.php',
|
61
|
'LoggerAppenderMail' => '/appenders/LoggerAppenderMail.php',
|
62
|
'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php',
|
63
|
'LoggerAppenderMongoDB' => '/appenders/LoggerAppenderMongoDB.php',
|
64
|
'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php',
|
65
|
'LoggerAppenderPDO' => '/appenders/LoggerAppenderPDO.php',
|
66
|
'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php',
|
67
|
'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php',
|
68
|
'LoggerAppenderSocket' => '/appenders/LoggerAppenderSocket.php',
|
69
|
'LoggerAppenderSyslog' => '/appenders/LoggerAppenderSyslog.php',
|
70
|
|
71
|
// Configurators
|
72
|
'LoggerConfigurationAdapter' => '/configurators/LoggerConfigurationAdapter.php',
|
73
|
'LoggerConfigurationAdapterINI' => '/configurators/LoggerConfigurationAdapterINI.php',
|
74
|
'LoggerConfigurationAdapterPHP' => '/configurators/LoggerConfigurationAdapterPHP.php',
|
75
|
'LoggerConfigurationAdapterXML' => '/configurators/LoggerConfigurationAdapterXML.php',
|
76
|
'LoggerConfiguratorDefault' => '/configurators/LoggerConfiguratorDefault.php',
|
77
|
|
78
|
// Filters
|
79
|
'LoggerFilter' => '/LoggerFilter.php',
|
80
|
'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php',
|
81
|
'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php',
|
82
|
'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php',
|
83
|
'LoggerFilterStringMatch' => '/filters/LoggerFilterStringMatch.php',
|
84
|
|
85
|
// Helpers
|
86
|
'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php',
|
87
|
'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php',
|
88
|
'LoggerPatternParser' => '/helpers/LoggerPatternParser.php',
|
89
|
|
90
|
// Converters
|
91
|
'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php',
|
92
|
'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php',
|
93
|
'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php',
|
94
|
'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php',
|
95
|
'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php',
|
96
|
'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php',
|
97
|
'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php',
|
98
|
'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php',
|
99
|
'LoggerPatternConverter' => '/helpers/LoggerPatternConverter.php',
|
100
|
|
101
|
// Layouts
|
102
|
'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php',
|
103
|
'LoggerLayoutPattern' => '/layouts/LoggerLayoutPattern.php',
|
104
|
'LoggerLayoutSerialized' => '/layouts/LoggerLayoutSerialized.php',
|
105
|
'LoggerLayoutSimple' => '/layouts/LoggerLayoutSimple.php',
|
106
|
'LoggerLayoutTTCC' => '/layouts/LoggerLayoutTTCC.php',
|
107
|
'LoggerLayoutXml' => '/layouts/LoggerLayoutXml.php',
|
108
|
|
109
|
// Renderers
|
110
|
'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php',
|
111
|
'LoggerRendererException' => '/renderers/LoggerRendererException.php',
|
112
|
'LoggerRendererMap' => '/renderers/LoggerRendererMap.php',
|
113
|
'LoggerRendererObject' => '/renderers/LoggerRendererObject.php',
|
114
|
);
|
115
|
|
116
|
/**
|
117
|
* Loads a class.
|
118
|
* @param string $className The name of the class to load.
|
119
|
*/
|
120
|
public static function autoload($className) {
|
121
|
if(isset(self::$classes[$className])) {
|
122
|
include dirname(__FILE__) . self::$classes[$className];
|
123
|
}
|
124
|
}
|
125
|
}
|