Version Notes
Release 0.3.0 (2012/12/12):
- Log4php library is updated to version 2.3.0;
- Log4php library is moved to '/lib' folder;
Download this release
Release Info
Developer | Alex |
Extension | nmmlm_log |
Version | 0.3.0 |
Comparing to | |
See all releases |
Code changes from version 0.2.1 to 0.3.0
- app/code/community/Nmmlm/Log/Logger.php +15 -10
- app/code/community/Nmmlm/Log/etc/release.txt +4 -0
- app/code/community/Nmmlm/Log/log4php/appenders/LoggerAppenderDailyFile.php +0 -110
- app/code/community/Nmmlm/Log/log4php/appenders/LoggerAppenderFile.php +0 -162
- app/code/community/Nmmlm/Log/log4php/appenders/LoggerAppenderPDO.php +0 -310
- app/code/community/Nmmlm/Log/log4php/appenders/LoggerAppenderRollingFile.php +0 -231
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerBasicPatternConverter.php +0 -71
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerDatePatternConverter.php +0 -53
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerLocationPatternConverter.php +0 -65
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerNamedPatternConverter.php +0 -77
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerOptionConverter.php +0 -451
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerPatternConverter.php +0 -134
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerPatternParser.php +0 -331
- app/code/community/Nmmlm/Log/log4php/layouts/LoggerLayoutPattern.php +0 -205
- app/code/community/Nmmlm/Log/log4php/renderers/LoggerRendererMap.php +0 -149
- app/code/community/Nmmlm/Log/log4php/renderers/LoggerRendererObject.php +0 -46
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/Logger.php +596 -576
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerAppender.php +286 -287
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerAppenderPool.php +2 -3
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerAutoloader.php +34 -17
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerConfigurable.php +2 -5
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerConfigurator.php +41 -41
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerException.php +28 -28
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerFilter.php +126 -126
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerHierarchy.php +257 -240
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerLayout.php +74 -74
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerLevel.php +256 -256
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerLocationInfo.php +103 -110
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerLoggingEvent.php +368 -362
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerMDC.php +88 -118
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerNDC.php +203 -203
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerReflectionUtils.php +152 -153
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerRoot.php +71 -70
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerThrowableInformation.php +2 -10
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderConsole.php +103 -105
- lib/Log4php/appenders/LoggerAppenderDailyFile.php +130 -0
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderEcho.php +88 -85
- lib/Log4php/appenders/LoggerAppenderFile.php +225 -0
- lib/Log4php/appenders/LoggerAppenderFirePHP.php +100 -0
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderMail.php +136 -113
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderMailEvent.php +180 -151
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderMemory.php +0 -0
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderMongoDB.php +360 -314
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderNull.php +44 -51
- lib/Log4php/appenders/LoggerAppenderPDO.php +282 -0
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderPhp.php +49 -56
- lib/Log4php/appenders/LoggerAppenderRollingFile.php +305 -0
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderSocket.php +122 -122
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderSyslog.php +303 -305
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfigurationAdapter.php +1 -2
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfigurationAdapterINI.php +1 -8
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfigurationAdapterPHP.php +1 -2
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfigurationAdapterXML.php +30 -10
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfiguratorDefault.php +25 -33
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/filters/LoggerFilterDenyAll.php +56 -56
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/filters/LoggerFilterLevelMatch.php +100 -100
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/filters/LoggerFilterLevelRange.php +138 -138
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/filters/LoggerFilterStringMatch.php +89 -89
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/helpers/LoggerFormattingInfo.php +54 -50
- lib/Log4php/helpers/LoggerOptionConverter.php +226 -0
- lib/Log4php/helpers/LoggerPatternParser.php +237 -0
- lib/Log4php/helpers/LoggerUtils.php +123 -0
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutHtml.php +214 -214
- lib/Log4php/layouts/LoggerLayoutPattern.php +171 -0
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutSerialized.php +1 -1
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutSimple.php +56 -56
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutTTCC.php +201 -197
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutXml.php +210 -210
- lib/Log4php/pattern/LoggerPatternConverter.php +131 -0
- lib/Log4php/pattern/LoggerPatternConverterClass.php +64 -0
- lib/Log4php/pattern/LoggerPatternConverterCookie.php +35 -0
- lib/Log4php/pattern/LoggerPatternConverterDate.php +91 -0
- lib/Log4php/pattern/LoggerPatternConverterEnvironment.php +35 -0
- lib/Log4php/pattern/LoggerPatternConverterFile.php +34 -0
- lib/Log4php/pattern/LoggerPatternConverterLevel.php +34 -0
- lib/Log4php/pattern/LoggerPatternConverterLine.php +35 -0
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerClassNamePatternConverter.php → lib/Log4php/pattern/LoggerPatternConverterLiteral.php +40 -45
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerLiteralPatternConverter.php → lib/Log4php/pattern/LoggerPatternConverterLocation.php +39 -57
- lib/Log4php/pattern/LoggerPatternConverterLogger.php +65 -0
- app/code/community/Nmmlm/Log/log4php/renderers/LoggerRendererDefault.php → lib/Log4php/pattern/LoggerPatternConverterMDC.php +55 -51
- lib/Log4php/pattern/LoggerPatternConverterMessage.php +34 -0
- lib/Log4php/pattern/LoggerPatternConverterMethod.php +35 -0
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerMDCPatternConverter.php → lib/Log4php/pattern/LoggerPatternConverterNDC.php +35 -50
- lib/Log4php/pattern/LoggerPatternConverterNewLine.php +34 -0
- lib/Log4php/pattern/LoggerPatternConverterProcess.php +34 -0
- lib/Log4php/pattern/LoggerPatternConverterRelative.php +36 -0
- lib/Log4php/pattern/LoggerPatternConverterRequest.php +35 -0
- lib/Log4php/pattern/LoggerPatternConverterServer.php +35 -0
- lib/Log4php/pattern/LoggerPatternConverterSession.php +35 -0
- lib/Log4php/pattern/LoggerPatternConverterSessionID.php +33 -0
- lib/Log4php/pattern/LoggerPatternConverterSuperglobal.php +102 -0
- lib/Log4php/pattern/LoggerPatternConverterThrowable.php +40 -0
- app/code/community/Nmmlm/Log/log4php/helpers/LoggerCategoryPatternConverter.php → lib/Log4php/renderers/LoggerRenderer.php +36 -44
- lib/Log4php/renderers/LoggerRendererDefault.php +36 -0
- {app/code/community/Nmmlm/Log/log4php → lib/Log4php}/renderers/LoggerRendererException.php +6 -11
- lib/Log4php/renderers/LoggerRendererMap.php +186 -0
- lib/Log4php/xml/log4php.dtd +148 -0
- package.xml +7 -5
app/code/community/Nmmlm/Log/Logger.php
CHANGED
@@ -25,15 +25,16 @@
|
|
25 |
* Time: 3:24 AM
|
26 |
*/
|
27 |
/* add log4php folders to include path */
|
28 |
-
$inc_base =
|
29 |
-
$add_path = $inc_base .
|
30 |
-
$add_path .= $inc_base .
|
31 |
-
$add_path .= $inc_base .
|
32 |
-
$add_path .= $inc_base .
|
33 |
-
$add_path .= $inc_base .
|
34 |
-
$add_path .= $inc_base .
|
35 |
-
$add_path .= $inc_base .
|
36 |
-
|
|
|
37 |
//
|
38 |
class Nmmlm_Log_Logger extends Logger
|
39 |
{
|
@@ -42,7 +43,9 @@ class Nmmlm_Log_Logger extends Logger
|
|
42 |
/**
|
43 |
* Override getter to use '$log = Nmmlm_Log_Logger::getLogger($this)' form in Mage classes.
|
44 |
* @static
|
|
|
45 |
* @param string $name
|
|
|
46 |
* @return Logger
|
47 |
*/
|
48 |
public static function getLogger($name)
|
@@ -62,7 +65,7 @@ class Nmmlm_Log_Logger extends Logger
|
|
62 |
private static function initMageLogger()
|
63 |
{
|
64 |
$dir = Mage::getBaseDir('base');
|
65 |
-
$file = $dir .
|
66 |
Nmmlm_Log_Logger::configure($file);
|
67 |
Nmmlm_Log_Logger::$isInitialized = true;
|
68 |
}
|
@@ -85,7 +88,9 @@ class Nmmlm_Log_Logger extends Logger
|
|
85 |
/**
|
86 |
* Convert Magento style package (Company_Module_Directory_Class) to log4php style package (Company.Module.Directory.Class).
|
87 |
* @static
|
|
|
88 |
* @param $name
|
|
|
89 |
* @return mixed
|
90 |
*/
|
91 |
private static function rewriteName($name)
|
25 |
* Time: 3:24 AM
|
26 |
*/
|
27 |
/* add log4php folders to include path */
|
28 |
+
$inc_base = Mage::getBaseDir('lib') . DS . 'Log4php';
|
29 |
+
$add_path = $inc_base . PS;
|
30 |
+
$add_path .= $inc_base . DS . 'appenders' . PS;
|
31 |
+
$add_path .= $inc_base . DS . 'configurators' . PS;
|
32 |
+
$add_path .= $inc_base . DS . 'filters' . PS;
|
33 |
+
$add_path .= $inc_base . DS . 'helpers' . PS;
|
34 |
+
$add_path .= $inc_base . DS . 'pattern' . PS;
|
35 |
+
$add_path .= $inc_base . DS . 'layouts' . PS;
|
36 |
+
$add_path .= $inc_base . DS . 'renderers';
|
37 |
+
set_include_path(get_include_path() . PS . $add_path);
|
38 |
//
|
39 |
class Nmmlm_Log_Logger extends Logger
|
40 |
{
|
43 |
/**
|
44 |
* Override getter to use '$log = Nmmlm_Log_Logger::getLogger($this)' form in Mage classes.
|
45 |
* @static
|
46 |
+
*
|
47 |
* @param string $name
|
48 |
+
*
|
49 |
* @return Logger
|
50 |
*/
|
51 |
public static function getLogger($name)
|
65 |
private static function initMageLogger()
|
66 |
{
|
67 |
$dir = Mage::getBaseDir('base');
|
68 |
+
$file = $dir . DS . Nmmlm_Log_Logger::cfgLog4phpConfigFile();
|
69 |
Nmmlm_Log_Logger::configure($file);
|
70 |
Nmmlm_Log_Logger::$isInitialized = true;
|
71 |
}
|
88 |
/**
|
89 |
* Convert Magento style package (Company_Module_Directory_Class) to log4php style package (Company.Module.Directory.Class).
|
90 |
* @static
|
91 |
+
*
|
92 |
* @param $name
|
93 |
+
*
|
94 |
* @return mixed
|
95 |
*/
|
96 |
private static function rewriteName($name)
|
app/code/community/Nmmlm/Log/etc/release.txt
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
Nmmlm_Log: Log4php Wrapper
|
2 |
|
|
|
|
|
|
|
|
|
3 |
Release 0.2.0 (2012/10/08):
|
4 |
- Extension is moved to 'community' pool;
|
5 |
- Logger transforms its name from Magento style "Company_Module_Class" to Log4php style "Company.Module.Style";
|
1 |
Nmmlm_Log: Log4php Wrapper
|
2 |
|
3 |
+
Release 0.3.0 (2012/12/12):
|
4 |
+
- Log4php library is updated to version 2.3.0;
|
5 |
+
- Log4php library is moved to '/lib' folder;
|
6 |
+
|
7 |
Release 0.2.0 (2012/10/08):
|
8 |
- Extension is moved to 'community' pool;
|
9 |
- Logger transforms its name from Magento style "Company_Module_Class" to Log4php style "Company.Module.Style";
|
app/code/community/Nmmlm/Log/log4php/appenders/LoggerAppenderDailyFile.php
DELETED
@@ -1,110 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* An Appender that automatically creates a new logfile each day.
|
23 |
-
*
|
24 |
-
* The file is rolled over once a day. That means, for each day a new file
|
25 |
-
* is created. A formatted version of the date pattern is used as to create
|
26 |
-
* the file name using the {@link PHP_MANUAL#sprintf} function.
|
27 |
-
*
|
28 |
-
* This appender uses a layout.
|
29 |
-
*
|
30 |
-
* Configurable parameters for this appender are:
|
31 |
-
* - datePattern - The date format for the file name. Should be set before
|
32 |
-
* $file. Default value: "Ymd".
|
33 |
-
* - file - The path to the target log file. The filename should
|
34 |
-
* contain a '%s' which will be substituted by the date.
|
35 |
-
* - append - Sets if the appender should append to the end of the
|
36 |
-
* file or overwrite content ("true" or "false"). Default
|
37 |
-
* value: true.
|
38 |
-
*
|
39 |
-
* An example php file:
|
40 |
-
*
|
41 |
-
* {@example ../../examples/php/appender_dailyfile.php 19}
|
42 |
-
*
|
43 |
-
* An example configuration file:
|
44 |
-
*
|
45 |
-
* {@example ../../examples/resources/appender_dailyfile.properties 18}
|
46 |
-
*
|
47 |
-
* The above will create a file like: daily_20090908.log
|
48 |
-
*
|
49 |
-
* @version $Revision: 1213283 $
|
50 |
-
* @package log4php
|
51 |
-
* @subpackage appenders
|
52 |
-
*/
|
53 |
-
class LoggerAppenderDailyFile extends LoggerAppenderFile {
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Format date.
|
57 |
-
* It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>.
|
58 |
-
* @var string
|
59 |
-
*/
|
60 |
-
protected $datePattern = "Ymd";
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Sets date format for the file name.
|
64 |
-
* @param string $datePattern a regular date() string format
|
65 |
-
*/
|
66 |
-
public function setDatePattern($datePattern) {
|
67 |
-
$this->setString('datePattern', $datePattern);
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* @return string returns date format for the filename
|
72 |
-
*/
|
73 |
-
public function getDatePattern() {
|
74 |
-
return $this->datePattern;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Similar to parent method, but but replaces "%s" in the file name with
|
79 |
-
* the current date in format specified by the 'datePattern' parameter.
|
80 |
-
*/
|
81 |
-
public function activateOptions() {
|
82 |
-
$fileName = $this->getFile();
|
83 |
-
$date = date($this->getDatePattern());
|
84 |
-
$fileName = sprintf($fileName, $date);
|
85 |
-
|
86 |
-
if(!is_file($fileName)) {
|
87 |
-
$dir = dirname($fileName);
|
88 |
-
if(!is_dir($dir)) {
|
89 |
-
mkdir($dir, 0777, true);
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
$this->fp = fopen($fileName, ($this->getAppend()? 'a':'w'));
|
94 |
-
if($this->fp) {
|
95 |
-
if(flock($this->fp, LOCK_EX)) {
|
96 |
-
if($this->getAppend()) {
|
97 |
-
fseek($this->fp, 0, SEEK_END);
|
98 |
-
}
|
99 |
-
fwrite($this->fp, $this->layout->getHeader());
|
100 |
-
flock($this->fp, LOCK_UN);
|
101 |
-
$this->closed = false;
|
102 |
-
} else {
|
103 |
-
// TODO: should we take some action in this case?
|
104 |
-
$this->closed = true;
|
105 |
-
}
|
106 |
-
} else {
|
107 |
-
$this->closed = true;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/appenders/LoggerAppenderFile.php
DELETED
@@ -1,162 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* FileAppender appends log events to a file.
|
23 |
-
*
|
24 |
-
* This appender uses a layout.
|
25 |
-
*
|
26 |
-
* Configurable parameters for this appender are:
|
27 |
-
* - file - The target file to write to
|
28 |
-
* - filename - The target file to write to (deprecated, use "file" instead)
|
29 |
-
* - append - Sets if the appender should append to the end of the file or overwrite content ("true" or "false")
|
30 |
-
*
|
31 |
-
* An example php file:
|
32 |
-
*
|
33 |
-
* {@example ../../examples/php/appender_file.php 19}
|
34 |
-
*
|
35 |
-
* An example configuration file:
|
36 |
-
*
|
37 |
-
* {@example ../../examples/resources/appender_file.properties 18}
|
38 |
-
*
|
39 |
-
* @version $Revision: 1213663 $
|
40 |
-
* @package log4php
|
41 |
-
* @subpackage appenders
|
42 |
-
*/
|
43 |
-
class LoggerAppenderFile extends LoggerAppender {
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @var boolean if {@link $file} exists, appends events.
|
47 |
-
*/
|
48 |
-
protected $append = true;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @var string the file name used to append events
|
52 |
-
*/
|
53 |
-
protected $file;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @var mixed file resource
|
57 |
-
*/
|
58 |
-
protected $fp = false;
|
59 |
-
|
60 |
-
public function activateOptions() {
|
61 |
-
$fileName = $this->getFile();
|
62 |
-
|
63 |
-
if (empty($fileName)) {
|
64 |
-
$this->warn("Required parameter 'fileName' not set. Closing appender.");
|
65 |
-
$this->closed = true;
|
66 |
-
return;
|
67 |
-
}
|
68 |
-
|
69 |
-
if(!is_file($fileName)) {
|
70 |
-
$dir = dirname($fileName);
|
71 |
-
if(!is_dir($dir)) {
|
72 |
-
mkdir($dir, 0777, true);
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
$this->fp = fopen($fileName, ($this->getAppend()? 'a':'w'));
|
77 |
-
if($this->fp) {
|
78 |
-
if(flock($this->fp, LOCK_EX)) {
|
79 |
-
if($this->getAppend()) {
|
80 |
-
fseek($this->fp, 0, SEEK_END);
|
81 |
-
}
|
82 |
-
fwrite($this->fp, $this->layout->getHeader());
|
83 |
-
flock($this->fp, LOCK_UN);
|
84 |
-
$this->closed = false;
|
85 |
-
} else {
|
86 |
-
// TODO: should we take some action in this case?
|
87 |
-
$this->closed = true;
|
88 |
-
}
|
89 |
-
} else {
|
90 |
-
$this->closed = true;
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
public function close() {
|
95 |
-
if($this->closed != true) {
|
96 |
-
if($this->fp and $this->layout !== null) {
|
97 |
-
if(flock($this->fp, LOCK_EX)) {
|
98 |
-
fwrite($this->fp, $this->layout->getFooter());
|
99 |
-
flock($this->fp, LOCK_UN);
|
100 |
-
}
|
101 |
-
fclose($this->fp);
|
102 |
-
}
|
103 |
-
$this->closed = true;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
public function append(LoggerLoggingEvent $event) {
|
108 |
-
if($this->fp and $this->layout !== null) {
|
109 |
-
if(flock($this->fp, LOCK_EX)) {
|
110 |
-
fwrite($this->fp, $this->layout->format($event));
|
111 |
-
flock($this->fp, LOCK_UN);
|
112 |
-
} else {
|
113 |
-
$this->closed = true;
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Sets the file where the log output will go.
|
120 |
-
* @param string $file
|
121 |
-
*/
|
122 |
-
public function setFile($file) {
|
123 |
-
$this->setString('file', $file);
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* @return string
|
128 |
-
*/
|
129 |
-
public function getFile() {
|
130 |
-
return $this->file;
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* @return boolean
|
135 |
-
*/
|
136 |
-
public function getAppend() {
|
137 |
-
return $this->append;
|
138 |
-
}
|
139 |
-
|
140 |
-
public function setAppend($append) {
|
141 |
-
$this->setBoolean('append', $append);
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Sets the file where the log output will go.
|
146 |
-
* @param string $fileName
|
147 |
-
* @deprecated Use setFile() instead.
|
148 |
-
*/
|
149 |
-
public function setFileName($fileName) {
|
150 |
-
$this->setFile($fileName);
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* @return string
|
155 |
-
* @deprecated Use getFile() instead.
|
156 |
-
*/
|
157 |
-
public function getFileName() {
|
158 |
-
return $this->getFile();
|
159 |
-
}
|
160 |
-
|
161 |
-
|
162 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/appenders/LoggerAppenderPDO.php
DELETED
@@ -1,310 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* Appends log events to a db table using PDO.
|
23 |
-
*
|
24 |
-
* Configurable parameters of this appender are:
|
25 |
-
*
|
26 |
-
* - user - Sets the user of this database connection
|
27 |
-
* - password - Sets the password of this database connection
|
28 |
-
* - createTable - true, if the table should be created if necessary. false otherwise
|
29 |
-
* - table - Sets the table name (default: log4php_log)
|
30 |
-
* - sql - Sets the insert statement for a logging event. Defaults
|
31 |
-
* to the correct one - change only if you are sure what you are doing.
|
32 |
-
* - dsn - Sets the DSN string for this connection
|
33 |
-
*
|
34 |
-
* If $sql is set then $table and $sql are used, else $table, $insertSql and $insertPattern.
|
35 |
-
*
|
36 |
-
* An example:
|
37 |
-
*
|
38 |
-
* {@example ../../examples/php/appender_pdo.php 19}
|
39 |
-
*
|
40 |
-
* {@example ../../examples/resources/appender_pdo.properties 18}
|
41 |
-
*
|
42 |
-
* @version $Revision: 806678 $
|
43 |
-
* @package log4php
|
44 |
-
* @subpackage appenders
|
45 |
-
* @since 2.0
|
46 |
-
*/
|
47 |
-
class LoggerAppenderPDO extends LoggerAppender {
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Create the log table if it does not exists (optional).
|
51 |
-
* @var string
|
52 |
-
*/
|
53 |
-
protected $createTable = true;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Database user name.
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
protected $user;
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Database password
|
63 |
-
* @var string
|
64 |
-
*/
|
65 |
-
protected $password;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* DSN string for enabling a connection.
|
69 |
-
* @var string
|
70 |
-
*/
|
71 |
-
protected $dsn;
|
72 |
-
|
73 |
-
/**
|
74 |
-
* A {@link LoggerPatternLayout} string used to format a valid insert query.
|
75 |
-
* @deprecated Use {@link $insertSql} and {@link $insertPattern} which properly handle quotes in the messages!
|
76 |
-
* @var string
|
77 |
-
*/
|
78 |
-
protected $sql;
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Can be set to a complete insert statement with ? that are replaced using {@link insertPattern}.
|
82 |
-
* @var string
|
83 |
-
*/
|
84 |
-
protected $insertSql = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?,?,?,?,?,?,?)";
|
85 |
-
|
86 |
-
/**
|
87 |
-
* A comma separated list of {@link LoggerPatternLayout} format strings that replace the "?" in {@link $sql}.
|
88 |
-
* @var string
|
89 |
-
*/
|
90 |
-
protected $insertPattern = "%d,%c,%p,%m,%t,%F,%L";
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Table name to write events. Used only for CREATE TABLE if {@link $createTable} is true.
|
94 |
-
* @var string
|
95 |
-
*/
|
96 |
-
protected $table = 'log4php_log';
|
97 |
-
|
98 |
-
/**
|
99 |
-
* The PDO instance.
|
100 |
-
* @var PDO
|
101 |
-
*/
|
102 |
-
protected $db = null;
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Prepared statement for the INSERT INTO query.
|
106 |
-
* @var PDOStatement
|
107 |
-
*/
|
108 |
-
protected $preparedInsert;
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Set in activateOptions() and later used in append() to check if all conditions to append are true.
|
112 |
-
* @var boolean
|
113 |
-
*/
|
114 |
-
protected $canAppend = true;
|
115 |
-
|
116 |
-
/**
|
117 |
-
* This appender does not require a layout.
|
118 |
-
*/
|
119 |
-
protected $requiresLayout = false;
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Setup db connection.
|
123 |
-
* Based on defined options, this method connects to db defined in {@link $dsn}
|
124 |
-
* and creates a {@link $table} table if {@link $createTable} is true.
|
125 |
-
* @return boolean true if all ok.
|
126 |
-
* @throws a PDOException if the attempt to connect to the requested database fails.
|
127 |
-
*/
|
128 |
-
public function activateOptions() {
|
129 |
-
try {
|
130 |
-
if($this->user === null) {
|
131 |
-
$this->db = new PDO($this->dsn);
|
132 |
-
} else if($this->password === null) {
|
133 |
-
$this->db = new PDO($this->dsn, $this->user);
|
134 |
-
} else {
|
135 |
-
$this->db = new PDO($this->dsn,$this->user,$this->password);
|
136 |
-
}
|
137 |
-
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
138 |
-
|
139 |
-
// test if log table exists
|
140 |
-
try {
|
141 |
-
$result = $this->db->query('SELECT * FROM ' . $this->table . ' WHERE 1 = 0');
|
142 |
-
$result->closeCursor();
|
143 |
-
} catch (PDOException $e) {
|
144 |
-
// It could be something else but a "no such table" is the most likely
|
145 |
-
$result = false;
|
146 |
-
}
|
147 |
-
|
148 |
-
// create table if necessary
|
149 |
-
if ($result == false and $this->createTable) {
|
150 |
-
// The syntax should at least be compatible with MySQL, PostgreSQL, SQLite and Oracle.
|
151 |
-
$query = "CREATE TABLE {$this->table} (".
|
152 |
-
"timestamp varchar(32)," .
|
153 |
-
"logger varchar(64)," .
|
154 |
-
"level varchar(32)," .
|
155 |
-
"message varchar(9999)," .
|
156 |
-
"thread varchar(32)," .
|
157 |
-
"file varchar(255)," .
|
158 |
-
"line varchar(6))";
|
159 |
-
$result = $this->db->query($query);
|
160 |
-
}
|
161 |
-
} catch (PDOException $e) {
|
162 |
-
$this->canAppend = false;
|
163 |
-
throw new LoggerException($e);
|
164 |
-
}
|
165 |
-
|
166 |
-
$this->layout = new LoggerLayoutPattern();
|
167 |
-
|
168 |
-
//
|
169 |
-
// Keep compatibility to legacy option $sql which already included the format patterns!
|
170 |
-
//
|
171 |
-
if (empty($this->sql)) {
|
172 |
-
// new style with prepared Statment and $insertSql and $insertPattern
|
173 |
-
// Maybe the tablename has to be substituted.
|
174 |
-
$this->insertSql = preg_replace('/__TABLE__/', $this->table, $this->insertSql);
|
175 |
-
$this->preparedInsert = $this->db->prepare($this->insertSql);
|
176 |
-
$this->layout->setConversionPattern($this->insertPattern);
|
177 |
-
} else {
|
178 |
-
// Old style with format strings in the $sql query should be used.
|
179 |
-
$this->layout->setConversionPattern($this->sql);
|
180 |
-
}
|
181 |
-
|
182 |
-
$this->canAppend = true;
|
183 |
-
return true;
|
184 |
-
}
|
185 |
-
|
186 |
-
/**
|
187 |
-
* Appends a new event to the database.
|
188 |
-
*
|
189 |
-
* @throws LoggerException If the pattern conversion or the INSERT statement fails.
|
190 |
-
*/
|
191 |
-
public function append(LoggerLoggingEvent $event) {
|
192 |
-
// TODO: Can't activateOptions() simply throw an Exception if it encounters problems?
|
193 |
-
if ( ! $this->canAppend) return;
|
194 |
-
|
195 |
-
try {
|
196 |
-
if (empty($this->sql)) {
|
197 |
-
// new style with prepared statement
|
198 |
-
$params = $this->layout->formatToArray($event);
|
199 |
-
$this->preparedInsert->execute($params);
|
200 |
-
} else {
|
201 |
-
// old style
|
202 |
-
$query = $this->layout->format($event);
|
203 |
-
$this->db->exec($query);
|
204 |
-
}
|
205 |
-
} catch (Exception $e) {
|
206 |
-
throw new LoggerException($e);
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Closes the connection to the logging database
|
212 |
-
*/
|
213 |
-
public function close() {
|
214 |
-
if($this->closed != true) {
|
215 |
-
if ($this->db !== null) {
|
216 |
-
$this->db = null;
|
217 |
-
}
|
218 |
-
$this->closed = true;
|
219 |
-
}
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Sets the username for this connection.
|
224 |
-
* Defaults to ''
|
225 |
-
*/
|
226 |
-
public function setUser($user) {
|
227 |
-
$this->setString('user', $user);
|
228 |
-
}
|
229 |
-
|
230 |
-
/**
|
231 |
-
* Sets the password for this connection.
|
232 |
-
* Defaults to ''
|
233 |
-
*/
|
234 |
-
public function setPassword($password) {
|
235 |
-
$this->setString('password', $password);
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Indicator if the logging table should be created on startup,
|
240 |
-
* if its not existing.
|
241 |
-
*/
|
242 |
-
public function setCreateTable($flag) {
|
243 |
-
$this->setBoolean('createTable', $flag);
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Sets the SQL string into which the event should be transformed.
|
248 |
-
* Defaults to:
|
249 |
-
*
|
250 |
-
* INSERT INTO $this->table
|
251 |
-
* ( timestamp, logger, level, message, thread, file, line)
|
252 |
-
* VALUES
|
253 |
-
* ('%d','%c','%p','%m','%t','%F','%L')
|
254 |
-
*
|
255 |
-
* It's not necessary to change this except you have customized logging'
|
256 |
-
*
|
257 |
-
* @deprecated See {@link setInsertSql} and {@link setInsertPattern}.
|
258 |
-
*/
|
259 |
-
public function setSql($sql) {
|
260 |
-
$this->setString('sql', $sql);
|
261 |
-
}
|
262 |
-
|
263 |
-
/**
|
264 |
-
* Sets the SQL INSERT string to use with {@link $insertPattern}.
|
265 |
-
*
|
266 |
-
* @param $sql A complete INSERT INTO query with "?" that gets replaced.
|
267 |
-
*/
|
268 |
-
public function setInsertSql($sql) {
|
269 |
-
$this->setString('insertSql', $sql);
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Sets the {@link LoggerLayoutPattern} format strings for {@link $insertSql}.
|
274 |
-
*
|
275 |
-
* It's not necessary to change this except you have customized logging.
|
276 |
-
*
|
277 |
-
* @param $pattern Comma separated format strings like "%p,%m,%C"
|
278 |
-
*/
|
279 |
-
public function setInsertPattern($pattern) {
|
280 |
-
$this->setString('insertPattern', $pattern);
|
281 |
-
}
|
282 |
-
|
283 |
-
/**
|
284 |
-
* Sets the tablename to which this appender should log.
|
285 |
-
* Defaults to log4php_log
|
286 |
-
*/
|
287 |
-
public function setTable($table) {
|
288 |
-
$this->setString('table', $table);
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Sets the DSN string for this connection. In case of
|
293 |
-
* SQLite it could look like this: 'sqlite:appenders/pdotest.sqlite'
|
294 |
-
*/
|
295 |
-
public function setDSN($dsn) {
|
296 |
-
$this->setString('dsn', $dsn);
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* Sometimes databases allow only one connection to themselves in one thread.
|
301 |
-
* SQLite has this behaviour. In that case this handle is needed if the database
|
302 |
-
* must be checked for events.
|
303 |
-
*
|
304 |
-
* @return PDO
|
305 |
-
*/
|
306 |
-
public function getDatabaseHandle() {
|
307 |
-
return $this->db;
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/appenders/LoggerAppenderRollingFile.php
DELETED
@@ -1,231 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* LoggerAppenderRollingFile extends LoggerAppenderFile to backup the log files
|
23 |
-
* when they reach a certain size.
|
24 |
-
*
|
25 |
-
* This appender uses a layout.
|
26 |
-
*
|
27 |
-
* Parameters are:
|
28 |
-
* - file - The target file to write to
|
29 |
-
* - filename - The target file to write to (deprecated, use "file" instead).
|
30 |
-
* - append - Sets if the appender should append to the end of the file or overwrite content ("true" or "false")
|
31 |
-
* - maxBackupIndex - Set the maximum number of backup files to keep around (int)
|
32 |
-
* - maxFileSize - Set the maximum size that the output file is allowed to
|
33 |
-
* reach before being rolled over to backup files.
|
34 |
-
* Suffixes like "KB", "MB" or "GB" are allowed, f. e. "10KB" is interpreted as 10240
|
35 |
-
* - maximumFileSize - Alias to maxFileSize (deprecated, use "maxFileSize" instead)
|
36 |
-
*
|
37 |
-
* <p>Contributors: Sergio Strampelli.</p>
|
38 |
-
*
|
39 |
-
* An example:
|
40 |
-
*
|
41 |
-
* {@example ../../examples/php/appender_socket.php 19}
|
42 |
-
*
|
43 |
-
* {@example ../../examples/resources/appender_socket.properties 18}
|
44 |
-
*
|
45 |
-
* @version $Revision: 1213283 $
|
46 |
-
* @package log4php
|
47 |
-
* @subpackage appenders
|
48 |
-
*/
|
49 |
-
class LoggerAppenderRollingFile extends LoggerAppenderFile {
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Set the maximum size that the output file is allowed to reach
|
53 |
-
* before being rolled over to backup files.
|
54 |
-
*
|
55 |
-
* <p>In configuration files, the <var>MaxFileSize</var> option takes a
|
56 |
-
* long integer in the range 0 - 2^63. You can specify the value
|
57 |
-
* with the suffixes "KB", "MB" or "GB" so that the integer is
|
58 |
-
* interpreted being expressed respectively in kilobytes, megabytes
|
59 |
-
* or gigabytes. For example, the value "10KB" will be interpreted
|
60 |
-
* as 10240.</p>
|
61 |
-
* <p>The default maximum file size is 10MB.</p>
|
62 |
-
*
|
63 |
-
* <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p>
|
64 |
-
*
|
65 |
-
* @var integer
|
66 |
-
*/
|
67 |
-
protected $maxFileSize = 10485760;
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Set the maximum number of backup files to keep around.
|
71 |
-
*
|
72 |
-
* <p>The <var>MaxBackupIndex</var> option determines how many backup
|
73 |
-
* files are kept before the oldest is erased. This option takes
|
74 |
-
* a positive integer value. If set to zero, then there will be no
|
75 |
-
* backup files and the log file will be truncated when it reaches
|
76 |
-
* MaxFileSize.</p>
|
77 |
-
* <p>There is one backup file by default.</p>
|
78 |
-
*
|
79 |
-
* @var integer
|
80 |
-
*/
|
81 |
-
protected $maxBackupIndex = 1;
|
82 |
-
|
83 |
-
/**
|
84 |
-
* @var string the filename expanded
|
85 |
-
*/
|
86 |
-
private $expandedFileName = null;
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Returns the value of the MaxBackupIndex option.
|
90 |
-
* @return integer
|
91 |
-
*/
|
92 |
-
private function getExpandedFileName() {
|
93 |
-
return $this->expandedFileName;
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Get the maximum size that the output file is allowed to reach
|
98 |
-
* before being rolled over to backup files.
|
99 |
-
* @return integer
|
100 |
-
*/
|
101 |
-
public function getMaximumFileSize() {
|
102 |
-
return $this->maxFileSize;
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Implements the usual roll over behaviour.
|
107 |
-
*
|
108 |
-
* <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
|
109 |
-
* Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
|
110 |
-
*
|
111 |
-
* <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
|
112 |
-
*
|
113 |
-
* Rollover must be called while the file is locked so that it is safe for concurrent access.
|
114 |
-
*/
|
115 |
-
private function rollOver() {
|
116 |
-
// If maxBackups <= 0, then there is no file renaming to be done.
|
117 |
-
if($this->maxBackupIndex > 0) {
|
118 |
-
$fileName = $this->getExpandedFileName();
|
119 |
-
|
120 |
-
// Delete the oldest file, to keep Windows happy.
|
121 |
-
$file = $fileName . '.' . $this->maxBackupIndex;
|
122 |
-
if(is_writable($file))
|
123 |
-
unlink($file);
|
124 |
-
|
125 |
-
// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
|
126 |
-
for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
|
127 |
-
$file = $fileName . "." . $i;
|
128 |
-
if(is_readable($file)) {
|
129 |
-
$target = $fileName . '.' . ($i + 1);
|
130 |
-
rename($file, $target);
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
// Backup the active file
|
135 |
-
copy($fileName, "$fileName.1");
|
136 |
-
}
|
137 |
-
|
138 |
-
// Truncate the active file
|
139 |
-
ftruncate($this->fp, 0);
|
140 |
-
rewind($this->fp);
|
141 |
-
}
|
142 |
-
|
143 |
-
public function setFile($fileName) {
|
144 |
-
$this->file = $fileName;
|
145 |
-
// As LoggerAppenderFile does not create the directory, it has to exist.
|
146 |
-
// realpath() fails if the argument does not exist so the filename is separated.
|
147 |
-
$this->expandedFileName = realpath(dirname($fileName));
|
148 |
-
if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!");
|
149 |
-
$this->expandedFileName .= DIRECTORY_SEPARATOR . basename($fileName);
|
150 |
-
}
|
151 |
-
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Set the maximum number of backup files to keep around.
|
155 |
-
*
|
156 |
-
* <p>The <b>MaxBackupIndex</b> option determines how many backup
|
157 |
-
* files are kept before the oldest is erased. This option takes
|
158 |
-
* a positive integer value. If set to zero, then there will be no
|
159 |
-
* backup files and the log file will be truncated when it reaches
|
160 |
-
* MaxFileSize.
|
161 |
-
*
|
162 |
-
* @param mixed $maxBackups
|
163 |
-
*/
|
164 |
-
public function setMaxBackupIndex($maxBackups) {
|
165 |
-
$this->setPositiveInteger('maxBackupIndex', $maxBackups);
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Set the maximum size that the output file is allowed to reach
|
170 |
-
* before being rolled over to backup files.
|
171 |
-
*
|
172 |
-
* @param mixed $maxFileSize
|
173 |
-
* @see setMaxFileSize()
|
174 |
-
* @deprecated
|
175 |
-
*/
|
176 |
-
public function setMaximumFileSize($maxFileSize) {
|
177 |
-
return $this->setMaxFileSize($maxFileSize);
|
178 |
-
}
|
179 |
-
|
180 |
-
/**
|
181 |
-
* Set the maximum size that the output file is allowed to reach
|
182 |
-
* before being rolled over to backup files.
|
183 |
-
* <p>In configuration files, the <b>maxFileSize</b> option takes an
|
184 |
-
* long integer in the range 0 - 2^63. You can specify the value
|
185 |
-
* with the suffixes "KB", "MB" or "GB" so that the integer is
|
186 |
-
* interpreted being expressed respectively in kilobytes, megabytes
|
187 |
-
* or gigabytes. For example, the value "10KB" will be interpreted
|
188 |
-
* as 10240.
|
189 |
-
*
|
190 |
-
* @param mixed $value
|
191 |
-
* @return the actual file size set
|
192 |
-
*/
|
193 |
-
public function setMaxFileSize($value) {
|
194 |
-
$this->setFileSize('maxFileSize', $value);
|
195 |
-
}
|
196 |
-
|
197 |
-
public function append(LoggerLoggingEvent $event) {
|
198 |
-
if($this->fp and $this->layout !== null) {
|
199 |
-
if(flock($this->fp, LOCK_EX)) {
|
200 |
-
fwrite($this->fp, $this->layout->format($event));
|
201 |
-
|
202 |
-
// Stats cache must be cleared, otherwise filesize() returns cached results
|
203 |
-
clearstatcache();
|
204 |
-
|
205 |
-
// Rollover if needed
|
206 |
-
if (filesize($this->expandedFileName) > $this->maxFileSize) {
|
207 |
-
$this->rollOver();
|
208 |
-
}
|
209 |
-
|
210 |
-
flock($this->fp, LOCK_UN);
|
211 |
-
} else {
|
212 |
-
$this->closed = true;
|
213 |
-
}
|
214 |
-
}
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* @return Returns the maximum number of backup files to keep around.
|
219 |
-
*/
|
220 |
-
public function getMaxBackupIndex() {
|
221 |
-
return $this->maxBackupIndex;
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* @return Returns the maximum size that the output file is allowed to reach
|
226 |
-
* before being rolled over to backup files.
|
227 |
-
*/
|
228 |
-
public function getMaxFileSize() {
|
229 |
-
return $this->maxFileSize;
|
230 |
-
}
|
231 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerBasicPatternConverter.php
DELETED
@@ -1,71 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* @package log4php
|
23 |
-
* @subpackage helpers
|
24 |
-
*/
|
25 |
-
class LoggerBasicPatternConverter extends LoggerPatternConverter {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var integer
|
29 |
-
*/
|
30 |
-
private $type;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Constructor
|
34 |
-
*
|
35 |
-
* @param string $formattingInfo
|
36 |
-
* @param integer $type
|
37 |
-
*/
|
38 |
-
public function __construct($formattingInfo, $type) {
|
39 |
-
parent::__construct($formattingInfo);
|
40 |
-
$this->type = $type;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @param LoggerLoggingEvent $event
|
45 |
-
* @return string
|
46 |
-
*/
|
47 |
-
public function convert($event) {
|
48 |
-
switch($this->type) {
|
49 |
-
case LoggerPatternParser::RELATIVE_TIME_CONVERTER:
|
50 |
-
$timeStamp = $event->getTimeStamp();
|
51 |
-
$startTime = LoggerLoggingEvent::getStartTime();
|
52 |
-
return (string)(int)($timeStamp * 1000 - $startTime * 1000);
|
53 |
-
|
54 |
-
case LoggerPatternParser::THREAD_CONVERTER:
|
55 |
-
return $event->getThreadName();
|
56 |
-
|
57 |
-
case LoggerPatternParser::LEVEL_CONVERTER:
|
58 |
-
$level = $event->getLevel();
|
59 |
-
return $level->toString();
|
60 |
-
|
61 |
-
case LoggerPatternParser::NDC_CONVERTER:
|
62 |
-
return $event->getNDC();
|
63 |
-
|
64 |
-
case LoggerPatternParser::MESSAGE_CONVERTER:
|
65 |
-
return $event->getRenderedMessage();
|
66 |
-
|
67 |
-
default:
|
68 |
-
return '';
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerDatePatternConverter.php
DELETED
@@ -1,53 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* @package log4php
|
23 |
-
* @subpackage helpers
|
24 |
-
*/
|
25 |
-
class LoggerDatePatternConverter extends LoggerPatternConverter {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var string
|
29 |
-
*/
|
30 |
-
private $df;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Constructor
|
34 |
-
*
|
35 |
-
* @param string $formattingInfo
|
36 |
-
* @param string $df
|
37 |
-
*/
|
38 |
-
public function __construct($formattingInfo, $df) {
|
39 |
-
parent::__construct($formattingInfo);
|
40 |
-
$this->df = $df;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @param LoggerLoggingEvent $event
|
45 |
-
* @return string
|
46 |
-
*/
|
47 |
-
public function convert($event) {
|
48 |
-
$timeStamp = $event->getTimeStamp();
|
49 |
-
$usecs = round(($timeStamp - (int)$timeStamp) * 1000);
|
50 |
-
$df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df);
|
51 |
-
return date($df, $timeStamp);
|
52 |
-
}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerLocationPatternConverter.php
DELETED
@@ -1,65 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* @package log4php
|
23 |
-
* @subpackage helpers
|
24 |
-
*/
|
25 |
-
class LoggerLocationPatternConverter extends LoggerPatternConverter {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var integer
|
29 |
-
*/
|
30 |
-
private $type;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Constructor
|
34 |
-
*
|
35 |
-
* @param string $formattingInfo
|
36 |
-
* @param integer $type
|
37 |
-
*/
|
38 |
-
public function __construct($formattingInfo, $type) {
|
39 |
-
parent::__construct($formattingInfo);
|
40 |
-
$this->type = $type;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @param LoggerLoggingEvent $event
|
45 |
-
* @return string
|
46 |
-
*/
|
47 |
-
public function convert($event) {
|
48 |
-
$locationInfo = $event->getLocationInformation();
|
49 |
-
switch($this->type) {
|
50 |
-
case LoggerPatternParser::FULL_LOCATION_CONVERTER:
|
51 |
-
return $locationInfo->getFullInfo();
|
52 |
-
case LoggerPatternParser::METHOD_LOCATION_CONVERTER:
|
53 |
-
return $locationInfo->getMethodName();
|
54 |
-
case LoggerPatternParser::LINE_LOCATION_CONVERTER:
|
55 |
-
return $locationInfo->getLineNumber();
|
56 |
-
case LoggerPatternParser::FILE_LOCATION_CONVERTER:
|
57 |
-
return $locationInfo->getFileName();
|
58 |
-
case LoggerPatternParser::CLASS_LOCATION_CONVERTER:
|
59 |
-
return $locationInfo->getFullQualifiedClassname();
|
60 |
-
default:
|
61 |
-
return '';
|
62 |
-
}
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerNamedPatternConverter.php
DELETED
@@ -1,77 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* @package log4php
|
23 |
-
* @subpackage helpers
|
24 |
-
*/
|
25 |
-
class LoggerNamedPatternConverter extends LoggerPatternConverter {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var integer
|
29 |
-
*/
|
30 |
-
private $precision;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Constructor
|
34 |
-
*
|
35 |
-
* @param string $formattingInfo
|
36 |
-
* @param integer $precision
|
37 |
-
*/
|
38 |
-
public function __construct($formattingInfo, $precision) {
|
39 |
-
parent::__construct($formattingInfo);
|
40 |
-
$this->precision = $precision;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @param LoggerLoggingEvent $event
|
45 |
-
* @return string
|
46 |
-
*/
|
47 |
-
public function getFullyQualifiedName($event) {
|
48 |
-
return;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @param LoggerLoggingEvent $event
|
53 |
-
* @return string
|
54 |
-
*/
|
55 |
-
function convert($event) {
|
56 |
-
$n = $this->getFullyQualifiedName($event);
|
57 |
-
if($this->precision <= 0) {
|
58 |
-
return $n;
|
59 |
-
} else {
|
60 |
-
|
61 |
-
// TODO: do this with explode()
|
62 |
-
|
63 |
-
$len = strlen($n);
|
64 |
-
// We substract 1 from 'len' when assigning to 'end' to avoid out of
|
65 |
-
// bounds exception in return r.substring(end+1, len). This can happen if
|
66 |
-
// precision is 1 and the category name ends with a dot.
|
67 |
-
$end = $len -1 ;
|
68 |
-
for($i = $this->precision; $i > 0; $i--) {
|
69 |
-
$end = strrpos(substr($n, 0, ($end - 1)), '.');
|
70 |
-
if($end == false) {
|
71 |
-
return $n;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
return substr($n, ($end + 1), $len);
|
75 |
-
}
|
76 |
-
}
|
77 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerOptionConverter.php
DELETED
@@ -1,451 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* A convenience class to convert property values to specific types.
|
23 |
-
*
|
24 |
-
* @version $Revision: 1237446 $
|
25 |
-
* @package log4php
|
26 |
-
* @subpackage helpers
|
27 |
-
* @since 0.5
|
28 |
-
*/
|
29 |
-
class LoggerOptionConverter {
|
30 |
-
|
31 |
-
const DELIM_START = '${';
|
32 |
-
const DELIM_STOP = '}';
|
33 |
-
const DELIM_START_LEN = 2;
|
34 |
-
const DELIM_STOP_LEN = 1;
|
35 |
-
|
36 |
-
/** String values which are converted to boolean TRUE. */
|
37 |
-
private static $trueValues = array('1', 'true', 'yes', 'on');
|
38 |
-
|
39 |
-
/**
|
40 |
-
* String values which are converted to boolean FALSE.
|
41 |
-
*
|
42 |
-
* Note that an empty string must convert to false, because
|
43 |
-
* parse_ini_file() which is used for parsing configuration
|
44 |
-
* converts the value _false_ to an empty string.
|
45 |
-
*/
|
46 |
-
private static $falseValues = array('0', 'false', 'no', 'off', '');
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Read a predefined var.
|
50 |
-
*
|
51 |
-
* It returns a value referenced by <var>$key</var> using this search criteria:
|
52 |
-
* - if <var>$key</var> is a constant then return it. Else
|
53 |
-
* - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
|
54 |
-
* - return <var>$def</var>.
|
55 |
-
*
|
56 |
-
* @param string $key The key to search for.
|
57 |
-
* @param string $def The default value to return.
|
58 |
-
* @return string the string value of the system property, or the default
|
59 |
-
* value if there is no property with that key.
|
60 |
-
*/
|
61 |
-
public static function getSystemProperty($key, $def) {
|
62 |
-
if(defined($key)) {
|
63 |
-
return (string)constant($key);
|
64 |
-
} else if(isset($_SERVER[$key])) {
|
65 |
-
return (string)$_SERVER[$key];
|
66 |
-
} else if(isset($_ENV[$key])) {
|
67 |
-
return (string)$_ENV[$key];
|
68 |
-
} else {
|
69 |
-
return $def;
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* If <var>$value</var> is <i>true</i>, then <i>true</i> is
|
75 |
-
* returned. If <var>$value</var> is <i>false</i>, then
|
76 |
-
* <i>true</i> is returned. Otherwise, <var>$default</var> is
|
77 |
-
* returned.
|
78 |
-
*
|
79 |
-
* <p>Case of value is unimportant.</p>
|
80 |
-
*
|
81 |
-
* @param string $value
|
82 |
-
* @param boolean $default
|
83 |
-
* @return boolean
|
84 |
-
*/
|
85 |
-
public static function toBoolean($value, $default=true) {
|
86 |
-
if (is_null($value)) {
|
87 |
-
return $default;
|
88 |
-
} elseif (is_string($value)) {
|
89 |
-
$trimmedVal = strtolower(trim($value));
|
90 |
-
if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) {
|
91 |
-
return true;
|
92 |
-
} else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) {
|
93 |
-
return false;
|
94 |
-
}
|
95 |
-
} elseif (is_bool($value)) {
|
96 |
-
return $value;
|
97 |
-
} elseif (is_int($value)) {
|
98 |
-
return !($value == 0); // true is everything but 0 like in C
|
99 |
-
}
|
100 |
-
|
101 |
-
return $default;
|
102 |
-
}
|
103 |
-
|
104 |
-
/** Converts $value to boolean, or throws an exception if not possible. */
|
105 |
-
public static function toBooleanEx($value) {
|
106 |
-
if (isset($value)) {
|
107 |
-
if (is_bool($value)) {
|
108 |
-
return $value;
|
109 |
-
}
|
110 |
-
$value = strtolower(trim($value));
|
111 |
-
if (in_array($value, self::$trueValues)) {
|
112 |
-
return true;
|
113 |
-
}
|
114 |
-
if (in_array($value, self::$falseValues)) {
|
115 |
-
return false;
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* @param string $value
|
124 |
-
* @param integer $default
|
125 |
-
* @return integer
|
126 |
-
*/
|
127 |
-
public static function toInt($value, $default) {
|
128 |
-
$value = trim($value);
|
129 |
-
if(is_numeric($value)) {
|
130 |
-
return (int)$value;
|
131 |
-
} else {
|
132 |
-
return $default;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Converts $value to integer, or throws an exception if not possible.
|
139 |
-
* Floats cannot be converted to integer.
|
140 |
-
*/
|
141 |
-
public static function toIntegerEx($value) {
|
142 |
-
if (is_integer($value)) {
|
143 |
-
return $value;
|
144 |
-
}
|
145 |
-
if (is_numeric($value) && ($value == (integer) $value)) {
|
146 |
-
return (integer) $value;
|
147 |
-
}
|
148 |
-
|
149 |
-
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Converts $value to integer, or throws an exception if not possible.
|
154 |
-
* Floats cannot be converted to integer.
|
155 |
-
*/
|
156 |
-
public static function toPositiveIntegerEx($value) {
|
157 |
-
if (is_integer($value) && $value > 0) {
|
158 |
-
return $value;
|
159 |
-
}
|
160 |
-
if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
|
161 |
-
return (integer) $value;
|
162 |
-
}
|
163 |
-
|
164 |
-
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Converts a standard or custom priority level to a Level
|
169 |
-
* object.
|
170 |
-
*
|
171 |
-
* <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
|
172 |
-
* where <i>full_file_classname</i> means the class filename with path
|
173 |
-
* but without php extension, then the specified class' <i>toLevel()</i> method
|
174 |
-
* is called to process the specified level string; if no '#'
|
175 |
-
* character is present, then the default {@link LoggerLevel}
|
176 |
-
* class is used to process the level value.</p>
|
177 |
-
*
|
178 |
-
* <p>As a special case, if the <var>$value</var> parameter is
|
179 |
-
* equal to the string "NULL", then the value <i>null</i> will
|
180 |
-
* be returned.</p>
|
181 |
-
*
|
182 |
-
* <p>If any error occurs while converting the value to a level,
|
183 |
-
* the <var>$defaultValue</var> parameter, which may be
|
184 |
-
* <i>null</i>, is returned.</p>
|
185 |
-
*
|
186 |
-
* <p>Case of <var>$value</var> is insignificant for the level level, but is
|
187 |
-
* significant for the class name part, if present.</p>
|
188 |
-
*
|
189 |
-
* @param string $value
|
190 |
-
* @param LoggerLevel $defaultValue
|
191 |
-
* @return LoggerLevel a {@link LoggerLevel} or null
|
192 |
-
*/
|
193 |
-
public static function toLevel($value, $defaultValue) {
|
194 |
-
if($value === null) {
|
195 |
-
return $defaultValue;
|
196 |
-
}
|
197 |
-
$hashIndex = strpos($value, '#');
|
198 |
-
if($hashIndex === false) {
|
199 |
-
if("NULL" == strtoupper($value)) {
|
200 |
-
return null;
|
201 |
-
} else {
|
202 |
-
// no class name specified : use standard Level class
|
203 |
-
return LoggerLevel::toLevel($value, $defaultValue);
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
$result = $defaultValue;
|
208 |
-
|
209 |
-
$clazz = substr($value, ($hashIndex + 1));
|
210 |
-
$levelName = substr($value, 0, $hashIndex);
|
211 |
-
|
212 |
-
// This is degenerate case but you never know.
|
213 |
-
if("NULL" == strtoupper($levelName)) {
|
214 |
-
return null;
|
215 |
-
}
|
216 |
-
|
217 |
-
$clazz = basename($clazz);
|
218 |
-
|
219 |
-
if(class_exists($clazz)) {
|
220 |
-
$result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
|
221 |
-
if(!$result instanceof LoggerLevel) {
|
222 |
-
$result = $defaultValue;
|
223 |
-
}
|
224 |
-
}
|
225 |
-
return $result;
|
226 |
-
}
|
227 |
-
|
228 |
-
|
229 |
-
/** Converts the value to a level. Throws an exception if not possible. */
|
230 |
-
public static function toLevelEx($value) {
|
231 |
-
if ($value instanceof LoggerLevel) {
|
232 |
-
return $value;
|
233 |
-
}
|
234 |
-
$level = LoggerLevel::toLevel($value);
|
235 |
-
if ($level === null) {
|
236 |
-
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
|
237 |
-
}
|
238 |
-
return $level;
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* @param string $value
|
243 |
-
* @param float $default
|
244 |
-
* @return float
|
245 |
-
*/
|
246 |
-
public static function toFileSize($value, $default) {
|
247 |
-
if($value === null) {
|
248 |
-
return $default;
|
249 |
-
}
|
250 |
-
|
251 |
-
$s = strtoupper(trim($value));
|
252 |
-
$multiplier = (float)1;
|
253 |
-
if(($index = strpos($s, 'KB')) !== false) {
|
254 |
-
$multiplier = 1024;
|
255 |
-
$s = substr($s, 0, $index);
|
256 |
-
} else if(($index = strpos($s, 'MB')) !== false) {
|
257 |
-
$multiplier = 1024 * 1024;
|
258 |
-
$s = substr($s, 0, $index);
|
259 |
-
} else if(($index = strpos($s, 'GB')) !== false) {
|
260 |
-
$multiplier = 1024 * 1024 * 1024;
|
261 |
-
$s = substr($s, 0, $index);
|
262 |
-
}
|
263 |
-
if(is_numeric($s)) {
|
264 |
-
return (float)$s * $multiplier;
|
265 |
-
}
|
266 |
-
return $default;
|
267 |
-
}
|
268 |
-
|
269 |
-
|
270 |
-
/**
|
271 |
-
* Converts a value to a valid file size (integer).
|
272 |
-
*
|
273 |
-
* Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc.
|
274 |
-
*
|
275 |
-
* The final value will be rounded to the nearest integer.
|
276 |
-
*
|
277 |
-
* Examples:
|
278 |
-
* - '100' => 100
|
279 |
-
* - '100.12' => 100
|
280 |
-
* - '100KB' => 102400
|
281 |
-
* - '1.5MB' => 1572864
|
282 |
-
*
|
283 |
-
* @param mixed $value File size (optionally with suffix).
|
284 |
-
* @return integer Parsed file size.
|
285 |
-
*/
|
286 |
-
public static function toFileSizeEx($value) {
|
287 |
-
|
288 |
-
if (empty($value)) {
|
289 |
-
throw new LoggerException("Empty value cannot be converted to a file size.");
|
290 |
-
}
|
291 |
-
|
292 |
-
if (is_numeric($value)) {
|
293 |
-
return (integer) $value;
|
294 |
-
}
|
295 |
-
|
296 |
-
if (!is_string($value)) {
|
297 |
-
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
|
298 |
-
}
|
299 |
-
|
300 |
-
$str = strtoupper(trim($value));
|
301 |
-
$count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches);
|
302 |
-
|
303 |
-
if ($count > 0) {
|
304 |
-
$size = $matches[1];
|
305 |
-
$unit = $matches[2];
|
306 |
-
|
307 |
-
switch($unit) {
|
308 |
-
case 'KB': $size *= pow(1024, 1); break;
|
309 |
-
case 'MB': $size *= pow(1024, 2); break;
|
310 |
-
case 'GB': $size *= pow(1024, 3); break;
|
311 |
-
}
|
312 |
-
|
313 |
-
return (integer) $size;
|
314 |
-
}
|
315 |
-
|
316 |
-
throw new LoggerException("Given value [$value] cannot be converted to a file size.");
|
317 |
-
}
|
318 |
-
|
319 |
-
/**
|
320 |
-
* Converts a value to string, or throws an exception if not possible.
|
321 |
-
*
|
322 |
-
* Objects can be converted to string if they implement the magic
|
323 |
-
* __toString() method.
|
324 |
-
*
|
325 |
-
*/
|
326 |
-
public static function toStringEx($value) {
|
327 |
-
if (is_string($value)) {
|
328 |
-
return $value;
|
329 |
-
}
|
330 |
-
if (is_numeric($value)) {
|
331 |
-
return (string) $value;
|
332 |
-
}
|
333 |
-
if (is_object($value) && method_exists($value, '__toString')) {
|
334 |
-
return (string) $value;
|
335 |
-
}
|
336 |
-
|
337 |
-
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
|
338 |
-
}
|
339 |
-
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Find the value corresponding to <var>$key</var> in
|
343 |
-
* <var>$props</var>. Then perform variable substitution on the
|
344 |
-
* found value.
|
345 |
-
*
|
346 |
-
* @param string $key
|
347 |
-
* @param array $props
|
348 |
-
* @return string
|
349 |
-
*/
|
350 |
-
public static function findAndSubst($key, $props) {
|
351 |
-
$value = @$props[$key];
|
352 |
-
|
353 |
-
// If coming from the LoggerConfiguratorIni, some options were
|
354 |
-
// already mangled by parse_ini_file:
|
355 |
-
//
|
356 |
-
// not specified => never reaches this code
|
357 |
-
// ""|off|false|null => string(0) ""
|
358 |
-
// "1"|on|true => string(1) "1"
|
359 |
-
// "true" => string(4) "true"
|
360 |
-
// "false" => string(5) "false"
|
361 |
-
//
|
362 |
-
// As the integer 1 and the boolean true are therefore indistinguable
|
363 |
-
// it's up to the setter how to deal with it, they can not be cast
|
364 |
-
// into a boolean here. {@see toBoolean}
|
365 |
-
// Even an empty value has to be given to the setter as it has been
|
366 |
-
// explicitly set by the user and is different from an option which
|
367 |
-
// has not been specified and therefore keeps its default value.
|
368 |
-
//
|
369 |
-
// if(!empty($value)) {
|
370 |
-
return LoggerOptionConverter::substVars($value, $props);
|
371 |
-
// }
|
372 |
-
}
|
373 |
-
|
374 |
-
/**
|
375 |
-
* Perform variable substitution in string <var>$val</var> from the
|
376 |
-
* values of keys found with the {@link getSystemProperty()} method.
|
377 |
-
*
|
378 |
-
* <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
|
379 |
-
*
|
380 |
-
* <p>For example, if the "MY_CONSTANT" contains "value", then
|
381 |
-
* the call
|
382 |
-
* <code>
|
383 |
-
* $s = LoggerOptionConverter::substVars("Value of key is ${MY_CONSTANT}.");
|
384 |
-
* </code>
|
385 |
-
* will set the variable <i>$s</i> to "Value of key is value.".</p>
|
386 |
-
*
|
387 |
-
* <p>If no value could be found for the specified key, then the
|
388 |
-
* <var>$props</var> parameter is searched, if the value could not
|
389 |
-
* be found there, then substitution defaults to the empty string.</p>
|
390 |
-
*
|
391 |
-
* <p>For example, if {@link getSystemProperty()} cannot find any value for the key
|
392 |
-
* "inexistentKey", then the call
|
393 |
-
* <code>
|
394 |
-
* $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
|
395 |
-
* </code>
|
396 |
-
* will set <var>$s</var> to "Value of inexistentKey is []".</p>
|
397 |
-
*
|
398 |
-
* <p>A warn is thrown if <var>$val</var> contains a start delimeter "${"
|
399 |
-
* which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
|
400 |
-
*
|
401 |
-
* @param string $val The string on which variable substitution is performed.
|
402 |
-
* @param array $props
|
403 |
-
* @return string
|
404 |
-
*/
|
405 |
-
// TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd
|
406 |
-
public static function substVars($val, $props = null) {
|
407 |
-
$sbuf = '';
|
408 |
-
$i = 0;
|
409 |
-
while(true) {
|
410 |
-
$j = strpos($val, self::DELIM_START, $i);
|
411 |
-
if($j === false) {
|
412 |
-
// no more variables
|
413 |
-
if($i == 0) { // this is a simple string
|
414 |
-
return $val;
|
415 |
-
} else { // add the tail string which contails no variables and return the result.
|
416 |
-
$sbuf .= substr($val, $i);
|
417 |
-
return $sbuf;
|
418 |
-
}
|
419 |
-
} else {
|
420 |
-
|
421 |
-
$sbuf .= substr($val, $i, $j-$i);
|
422 |
-
$k = strpos($val, self::DELIM_STOP, $j);
|
423 |
-
if($k === false) {
|
424 |
-
// LoggerOptionConverter::substVars() has no closing brace. Opening brace
|
425 |
-
return '';
|
426 |
-
} else {
|
427 |
-
$j += self::DELIM_START_LEN;
|
428 |
-
$key = substr($val, $j, $k - $j);
|
429 |
-
// first try in System properties
|
430 |
-
$replacement = LoggerOptionConverter::getSystemProperty($key, null);
|
431 |
-
// then try props parameter
|
432 |
-
if($replacement == null and $props !== null) {
|
433 |
-
$replacement = @$props[$key];
|
434 |
-
}
|
435 |
-
|
436 |
-
if(!empty($replacement)) {
|
437 |
-
// Do variable substitution on the replacement string
|
438 |
-
// such that we can solve "Hello ${x2}" as "Hello p1"
|
439 |
-
// the where the properties are
|
440 |
-
// x1=p1
|
441 |
-
// x2=${x1}
|
442 |
-
$recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
|
443 |
-
$sbuf .= $recursiveReplacement;
|
444 |
-
}
|
445 |
-
$i = $k + self::DELIM_STOP_LEN;
|
446 |
-
}
|
447 |
-
}
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerPatternConverter.php
DELETED
@@ -1,134 +0,0 @@
|
|
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 |
-
|
22 |
-
/**
|
23 |
-
* LoggerPatternConverter is an abstract class that provides the formatting
|
24 |
-
* functionality that derived classes need.
|
25 |
-
*
|
26 |
-
* <p>Conversion specifiers in a conversion patterns are parsed to
|
27 |
-
* individual PatternConverters. Each of which is responsible for
|
28 |
-
* converting a logging event in a converter specific manner.</p>
|
29 |
-
*
|
30 |
-
* @version $Revision: 1166187 $
|
31 |
-
* @package log4php
|
32 |
-
* @subpackage helpers
|
33 |
-
* @since 0.3
|
34 |
-
*/
|
35 |
-
class LoggerPatternConverter {
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Array for fast space padding
|
39 |
-
* Used by {@link LoggerPatternConverter::spacePad()}.
|
40 |
-
*/
|
41 |
-
private $spaces = array(
|
42 |
-
" ", // 1 space
|
43 |
-
" ", // 2 spaces
|
44 |
-
" ", // 4 spaces
|
45 |
-
" ", // 8 spaces
|
46 |
-
" ", // 16 spaces
|
47 |
-
" "); // 32 spaces
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @var LoggerPatternConverter next converter in converter chain
|
51 |
-
*/
|
52 |
-
public $next = null;
|
53 |
-
|
54 |
-
public $min = -1;
|
55 |
-
public $max = 0x7FFFFFFF;
|
56 |
-
public $leftAlign = false;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Constructor
|
60 |
-
*
|
61 |
-
* @param LoggerFormattingInfo $fi
|
62 |
-
*/
|
63 |
-
public function __construct($fi = null) {
|
64 |
-
if($fi !== null) {
|
65 |
-
$this->min = $fi->min;
|
66 |
-
$this->max = $fi->max;
|
67 |
-
$this->leftAlign = $fi->leftAlign;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Derived pattern converters must override this method in order to
|
73 |
-
* convert conversion specifiers in the correct way.
|
74 |
-
*
|
75 |
-
* @param LoggerLoggingEvent $event
|
76 |
-
*/
|
77 |
-
public function convert($event) {}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* A template method for formatting in a converter specific way.
|
81 |
-
*
|
82 |
-
* @param string &$sbuf string buffer
|
83 |
-
* @param LoggerLoggingEvent $e
|
84 |
-
*/
|
85 |
-
public function format(&$sbuf, $e) {
|
86 |
-
$s = $this->convert($e);
|
87 |
-
|
88 |
-
if($s == null or empty($s)) {
|
89 |
-
if(0 < $this->min) {
|
90 |
-
$this->spacePad($sbuf, $this->min);
|
91 |
-
}
|
92 |
-
return;
|
93 |
-
}
|
94 |
-
|
95 |
-
$len = strlen($s);
|
96 |
-
|
97 |
-
if($len > $this->max) {
|
98 |
-
$sbuf .= substr($s , 0, ($len - $this->max));
|
99 |
-
} else if($len < $this->min) {
|
100 |
-
if($this->leftAlign) {
|
101 |
-
$sbuf .= $s;
|
102 |
-
$this->spacePad($sbuf, ($this->min - $len));
|
103 |
-
} else {
|
104 |
-
$this->spacePad($sbuf, ($this->min - $len));
|
105 |
-
$sbuf .= $s;
|
106 |
-
}
|
107 |
-
} else {
|
108 |
-
$sbuf .= $s;
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Fast space padding method.
|
114 |
-
*
|
115 |
-
* @param string &$sbuf string buffer
|
116 |
-
* @param integer $length pad length
|
117 |
-
*
|
118 |
-
* @todo reimplement using PHP string functions
|
119 |
-
*/
|
120 |
-
public function spacePad(&$sbuf, $length) {
|
121 |
-
while($length >= 32) {
|
122 |
-
$sbuf .= $this->spaces[5];
|
123 |
-
$length -= 32;
|
124 |
-
}
|
125 |
-
|
126 |
-
for($i = 4; $i >= 0; $i--) {
|
127 |
-
if(($length & (1<<$i)) != 0) {
|
128 |
-
$sbuf .= $this->spaces[$i];
|
129 |
-
}
|
130 |
-
}
|
131 |
-
|
132 |
-
// $sbuf = str_pad($sbuf, $length);
|
133 |
-
}
|
134 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerPatternParser.php
DELETED
@@ -1,331 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* Most of the work of the {@link LoggerPatternLayout} class
|
23 |
-
* is delegated to the {@link LoggerPatternParser} class.
|
24 |
-
*
|
25 |
-
* <p>It is this class that parses conversion patterns and creates
|
26 |
-
* a chained list of {@link LoggerPatternConverter} converters.</p>
|
27 |
-
*
|
28 |
-
* @version $Revision: 1163520 $
|
29 |
-
* @package log4php
|
30 |
-
* @subpackage helpers
|
31 |
-
*
|
32 |
-
* @since 0.3
|
33 |
-
*/
|
34 |
-
class LoggerPatternParser {
|
35 |
-
|
36 |
-
const ESCAPE_CHAR = '%';
|
37 |
-
|
38 |
-
const LITERAL_STATE = 0;
|
39 |
-
const CONVERTER_STATE = 1;
|
40 |
-
const MINUS_STATE = 2;
|
41 |
-
const DOT_STATE = 3;
|
42 |
-
const MIN_STATE = 4;
|
43 |
-
const MAX_STATE = 5;
|
44 |
-
|
45 |
-
const FULL_LOCATION_CONVERTER = 1000;
|
46 |
-
const METHOD_LOCATION_CONVERTER = 1001;
|
47 |
-
const CLASS_LOCATION_CONVERTER = 1002;
|
48 |
-
const FILE_LOCATION_CONVERTER = 1003;
|
49 |
-
const LINE_LOCATION_CONVERTER = 1004;
|
50 |
-
|
51 |
-
const RELATIVE_TIME_CONVERTER = 2000;
|
52 |
-
const THREAD_CONVERTER = 2001;
|
53 |
-
const LEVEL_CONVERTER = 2002;
|
54 |
-
const NDC_CONVERTER = 2003;
|
55 |
-
const MESSAGE_CONVERTER = 2004;
|
56 |
-
|
57 |
-
const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u';
|
58 |
-
const DATE_FORMAT_ABSOLUTE = 'H:i:s';
|
59 |
-
const DATE_FORMAT_DATE = 'd M Y H:i:s,u';
|
60 |
-
|
61 |
-
private $state;
|
62 |
-
private $currentLiteral;
|
63 |
-
private $patternLength;
|
64 |
-
private $i;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* @var LoggerPatternConverter
|
68 |
-
*/
|
69 |
-
private $head = null;
|
70 |
-
|
71 |
-
/**
|
72 |
-
* @var LoggerPatternConverter
|
73 |
-
*/
|
74 |
-
private $tail = null;
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @var LoggerFormattingInfo
|
78 |
-
*/
|
79 |
-
private $formattingInfo;
|
80 |
-
|
81 |
-
/**
|
82 |
-
* @var string pattern to parse
|
83 |
-
*/
|
84 |
-
private $pattern;
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Constructor
|
88 |
-
*
|
89 |
-
* @param string $pattern
|
90 |
-
*/
|
91 |
-
public function __construct($pattern) {
|
92 |
-
$this->pattern = $pattern;
|
93 |
-
$this->patternLength = strlen($pattern);
|
94 |
-
$this->formattingInfo = new LoggerFormattingInfo();
|
95 |
-
$this->state = self::LITERAL_STATE;
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* @param LoggerPatternConverter $pc
|
100 |
-
*/
|
101 |
-
public function addToList($pc) {
|
102 |
-
if($this->head == null) {
|
103 |
-
$this->head = $pc;
|
104 |
-
$this->tail = $this->head;
|
105 |
-
} else {
|
106 |
-
$this->tail->next = $pc;
|
107 |
-
$this->tail = $this->tail->next;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* @return string
|
113 |
-
*/
|
114 |
-
public function extractOption() {
|
115 |
-
if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) {
|
116 |
-
$end = strpos($this->pattern, '}' , $this->i);
|
117 |
-
if($end !== false) {
|
118 |
-
$r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
|
119 |
-
$this->i= $end + 1;
|
120 |
-
return $r;
|
121 |
-
}
|
122 |
-
}
|
123 |
-
return null;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* The option is expected to be in decimal and positive. In case of
|
128 |
-
* error, zero is returned.
|
129 |
-
*/
|
130 |
-
public function extractPrecisionOption() {
|
131 |
-
$opt = $this->extractOption();
|
132 |
-
$r = 0;
|
133 |
-
if($opt !== null) {
|
134 |
-
if(is_numeric($opt)) {
|
135 |
-
$r = (int)$opt;
|
136 |
-
if($r <= 0) {
|
137 |
-
$r = 0;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
return $r;
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
/** Parser.
|
146 |
-
*
|
147 |
-
* @return LoggerPatternConverter Returns $this->head.
|
148 |
-
*/
|
149 |
-
public function parse() {
|
150 |
-
$c = '';
|
151 |
-
$this->i = 0;
|
152 |
-
$this->currentLiteral = '';
|
153 |
-
while($this->i < $this->patternLength) {
|
154 |
-
$c = $this->pattern{$this->i++};
|
155 |
-
|
156 |
-
switch($this->state) {
|
157 |
-
case self::LITERAL_STATE:
|
158 |
-
// In literal state, the last char is always a literal.
|
159 |
-
if($this->i == $this->patternLength) {
|
160 |
-
$this->currentLiteral .= $c;
|
161 |
-
continue;
|
162 |
-
}
|
163 |
-
if($c == self::ESCAPE_CHAR) {
|
164 |
-
// peek at the next char.
|
165 |
-
switch($this->pattern{$this->i}) {
|
166 |
-
case self::ESCAPE_CHAR:
|
167 |
-
$this->currentLiteral .= $c;
|
168 |
-
$this->i++; // move pointer
|
169 |
-
break;
|
170 |
-
case 'n':
|
171 |
-
$this->currentLiteral .= PHP_EOL;
|
172 |
-
$this->i++; // move pointer
|
173 |
-
break;
|
174 |
-
default:
|
175 |
-
if(strlen($this->currentLiteral) != 0) {
|
176 |
-
$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
|
177 |
-
}
|
178 |
-
$this->currentLiteral = $c;
|
179 |
-
$this->state = self::CONVERTER_STATE;
|
180 |
-
$this->formattingInfo->reset();
|
181 |
-
}
|
182 |
-
} else {
|
183 |
-
$this->currentLiteral .= $c;
|
184 |
-
}
|
185 |
-
break;
|
186 |
-
case self::CONVERTER_STATE:
|
187 |
-
$this->currentLiteral .= $c;
|
188 |
-
switch($c) {
|
189 |
-
case '-':
|
190 |
-
$this->formattingInfo->leftAlign = true;
|
191 |
-
break;
|
192 |
-
case '.':
|
193 |
-
$this->state = self::DOT_STATE;
|
194 |
-
break;
|
195 |
-
default:
|
196 |
-
if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
|
197 |
-
$this->formattingInfo->min = ord($c) - ord('0');
|
198 |
-
$this->state = self::MIN_STATE;
|
199 |
-
} else {
|
200 |
-
$this->finalizeConverter($c);
|
201 |
-
}
|
202 |
-
} // switch
|
203 |
-
break;
|
204 |
-
case self::MIN_STATE:
|
205 |
-
$this->currentLiteral .= $c;
|
206 |
-
if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
|
207 |
-
$this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0'));
|
208 |
-
} else if ($c == '.') {
|
209 |
-
$this->state = self::DOT_STATE;
|
210 |
-
} else {
|
211 |
-
$this->finalizeConverter($c);
|
212 |
-
}
|
213 |
-
break;
|
214 |
-
case self::DOT_STATE:
|
215 |
-
$this->currentLiteral .= $c;
|
216 |
-
if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
|
217 |
-
$this->formattingInfo->max = ord($c) - ord('0');
|
218 |
-
$this->state = self::MAX_STATE;
|
219 |
-
} else {
|
220 |
-
$this->state = self::LITERAL_STATE;
|
221 |
-
}
|
222 |
-
break;
|
223 |
-
case self::MAX_STATE:
|
224 |
-
$this->currentLiteral .= $c;
|
225 |
-
if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
|
226 |
-
$this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
|
227 |
-
} else {
|
228 |
-
$this->finalizeConverter($c);
|
229 |
-
$this->state = self::LITERAL_STATE;
|
230 |
-
}
|
231 |
-
break;
|
232 |
-
} // switch
|
233 |
-
} // while
|
234 |
-
if(strlen($this->currentLiteral) != 0) {
|
235 |
-
$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
|
236 |
-
}
|
237 |
-
return $this->head;
|
238 |
-
}
|
239 |
-
|
240 |
-
public function finalizeConverter($c) {
|
241 |
-
$pc = null;
|
242 |
-
switch($c) {
|
243 |
-
case 'c':
|
244 |
-
$pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
|
245 |
-
$this->currentLiteral = '';
|
246 |
-
break;
|
247 |
-
case 'C':
|
248 |
-
$pc = new LoggerClassNamePatternConverter($this->formattingInfo, self::CLASS_LOCATION_CONVERTER);
|
249 |
-
$this->currentLiteral = '';
|
250 |
-
break;
|
251 |
-
case 'd':
|
252 |
-
$dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
|
253 |
-
$dOpt = $this->extractOption();
|
254 |
-
|
255 |
-
if($dOpt !== null)
|
256 |
-
$dateFormatStr = $dOpt;
|
257 |
-
|
258 |
-
if($dateFormatStr == 'ISO8601') {
|
259 |
-
$df = self::DATE_FORMAT_ISO8601;
|
260 |
-
} else if($dateFormatStr == 'ABSOLUTE') {
|
261 |
-
$df = self::DATE_FORMAT_ABSOLUTE;
|
262 |
-
} else if($dateFormatStr == 'DATE') {
|
263 |
-
$df = self::DATE_FORMAT_DATE;
|
264 |
-
} else {
|
265 |
-
$df = $dateFormatStr;
|
266 |
-
if($df == null) {
|
267 |
-
$df = self::DATE_FORMAT_ISO8601;
|
268 |
-
}
|
269 |
-
}
|
270 |
-
$pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
|
271 |
-
$this->currentLiteral = '';
|
272 |
-
break;
|
273 |
-
case 'F':
|
274 |
-
$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER);
|
275 |
-
$this->currentLiteral = '';
|
276 |
-
break;
|
277 |
-
case 'l':
|
278 |
-
$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER);
|
279 |
-
$this->currentLiteral = '';
|
280 |
-
break;
|
281 |
-
case 'L':
|
282 |
-
$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER);
|
283 |
-
$this->currentLiteral = '';
|
284 |
-
break;
|
285 |
-
case 'm':
|
286 |
-
$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER);
|
287 |
-
$this->currentLiteral = '';
|
288 |
-
break;
|
289 |
-
case 'M':
|
290 |
-
$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER);
|
291 |
-
$this->currentLiteral = '';
|
292 |
-
break;
|
293 |
-
case 'p':
|
294 |
-
$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER);
|
295 |
-
$this->currentLiteral = '';
|
296 |
-
break;
|
297 |
-
case 'r':
|
298 |
-
$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER);
|
299 |
-
$this->currentLiteral = '';
|
300 |
-
break;
|
301 |
-
case 't':
|
302 |
-
$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER);
|
303 |
-
$this->currentLiteral = '';
|
304 |
-
break;
|
305 |
-
case 'x':
|
306 |
-
$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER);
|
307 |
-
$this->currentLiteral = '';
|
308 |
-
break;
|
309 |
-
case 'X':
|
310 |
-
$xOpt = $this->extractOption();
|
311 |
-
$pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
|
312 |
-
$this->currentLiteral = '';
|
313 |
-
break;
|
314 |
-
default:
|
315 |
-
$pc = new LoggerLiteralPatternConverter($this->currentLiteral);
|
316 |
-
$this->currentLiteral = '';
|
317 |
-
}
|
318 |
-
$this->addConverter($pc);
|
319 |
-
}
|
320 |
-
|
321 |
-
public function addConverter($pc) {
|
322 |
-
$this->currentLiteral = '';
|
323 |
-
// Add the pattern converter to the list.
|
324 |
-
$this->addToList($pc);
|
325 |
-
// Next pattern is assumed to be a literal.
|
326 |
-
$this->state = self::LITERAL_STATE;
|
327 |
-
// Reset formatting info
|
328 |
-
$this->formattingInfo->reset();
|
329 |
-
}
|
330 |
-
}
|
331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/layouts/LoggerLayoutPattern.php
DELETED
@@ -1,205 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* A flexible layout configurable with pattern string.
|
23 |
-
*
|
24 |
-
* <p>Example:</p>
|
25 |
-
*
|
26 |
-
* {@example ../../examples/php/layout_pattern.php 19}<br>
|
27 |
-
*
|
28 |
-
* <p>with the following properties file:</p>
|
29 |
-
*
|
30 |
-
* {@example ../../examples/resources/layout_pattern.properties 18}<br>
|
31 |
-
*
|
32 |
-
* <p>would print the following:</p>
|
33 |
-
*
|
34 |
-
* <pre>
|
35 |
-
* 2009-09-09 00:27:35,787 [INFO] root: Hello World! (at src/examples/php/layout_pattern.php line 6)
|
36 |
-
* 2009-09-09 00:27:35,787 [DEBUG] root: Second line (at src/examples/php/layout_pattern.php line 7)
|
37 |
-
* </pre>
|
38 |
-
*
|
39 |
-
* <p>The conversion pattern is closely related to the conversion pattern of the printf function in C.
|
40 |
-
* A conversion pattern is composed of literal text and format control expressions called conversion specifiers.
|
41 |
-
* You are free to insert any literal text within the conversion pattern.</p>
|
42 |
-
*
|
43 |
-
* <p>Each conversion specifier starts with a percent sign (%) and is followed by optional
|
44 |
-
* format modifiers and a conversion character.</p>
|
45 |
-
*
|
46 |
-
* <p>The conversion character specifies the type of data, e.g. category, priority, date, thread name.
|
47 |
-
* The format modifiers control such things as field width, padding, left and right justification.</p>
|
48 |
-
*
|
49 |
-
* <p>Note that there is no explicit separator between text and conversion specifiers.</p>
|
50 |
-
*
|
51 |
-
* <p>The pattern parser knows when it has reached the end of a conversion specifier when it reads a conversion character.
|
52 |
-
* In the example above the conversion specifier %-5p means the priority of the logging event should be
|
53 |
-
* left justified to a width of five characters.</p>
|
54 |
-
*
|
55 |
-
* Not all log4j conversion characters are implemented. The recognized conversion characters are:
|
56 |
-
* - <b>c</b> Used to output the category of the logging event. The category conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.
|
57 |
-
* If a precision specifier is given, then only the corresponding number of right most components of the category name will be printed.
|
58 |
-
* By default the category name is printed in full.
|
59 |
-
* For example, for the category name "a.b.c" the pattern %c{2} will output "b.c".
|
60 |
-
* - <b>C</b> Used to output the fully qualified class name of the caller issuing the logging request.
|
61 |
-
* This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.
|
62 |
-
* If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed.
|
63 |
-
* By default the class name is output in fully qualified form.
|
64 |
-
* For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass".
|
65 |
-
* - <b>d</b> Used to output the date of the logging event.
|
66 |
-
* The date conversion specifier may be followed by a date format specifier enclosed between braces.
|
67 |
-
* The format specifier follows the {@link PHP_MANUAL#date} function.
|
68 |
-
* Note that the special character <b>u</b> is used to as microseconds replacement (to avoid replacement,
|
69 |
-
* use <b>\u</b>).
|
70 |
-
* For example, %d{H:i:s,u} or %d{d M Y H:i:s,u}. If no date format specifier is given then ISO8601 format is assumed.
|
71 |
-
* The date format specifier admits the same syntax as the time pattern string of the SimpleDateFormat.
|
72 |
-
* It is recommended to use the predefined log4php date formatters.
|
73 |
-
* These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying
|
74 |
-
* AbsoluteTimeDateFormat, DateTimeDateFormat and respectively ISO8601DateFormat.
|
75 |
-
* For example, %d{ISO8601} or %d{ABSOLUTE}.
|
76 |
-
* - <b>F</b> Used to output the file name where the logging request was issued.
|
77 |
-
* - <b>l</b> Used to output location information of the caller which generated the logging event.
|
78 |
-
* - <b>L</b> Used to output the line number from where the logging request was issued.
|
79 |
-
* - <b>m</b> Used to output the application supplied message associated with the logging event.
|
80 |
-
* - <b>M</b> Used to output the method name where the logging request was issued.
|
81 |
-
* - <b>p</b> Used to output the priority of the logging event.
|
82 |
-
* - <b>r</b> Used to output the number of milliseconds elapsed since the start of
|
83 |
-
* the application until the creation of the logging event.
|
84 |
-
* - <b>t</b> Used to output the name of the thread that generated the logging event.
|
85 |
-
* - <b>x</b> Used to output the NDC (nested diagnostic context) associated with
|
86 |
-
* the thread that generated the logging event.
|
87 |
-
* - <b>X</b> Used to output the MDC (mapped diagnostic context) associated with
|
88 |
-
* the thread that generated the logging event.
|
89 |
-
* The X conversion character must be followed by the key for the map placed between braces,
|
90 |
-
* as in <i>%X{clientNumber}</i> where clientNumber is the key.
|
91 |
-
* The value in the MDC corresponding to the key will be output.
|
92 |
-
* See {@link LoggerMDC} class for more details.
|
93 |
-
* - <b>%</b> The sequence %% outputs a single percent sign.
|
94 |
-
*
|
95 |
-
* <p>By default the relevant information is output as is.
|
96 |
-
* However, with the aid of format modifiers it is possible to change the minimum field width,
|
97 |
-
* the maximum field width and justification.</p>
|
98 |
-
*
|
99 |
-
* <p>The optional format modifier is placed between the percent sign and the conversion character.</p>
|
100 |
-
* <p>The first optional format modifier is the left justification flag which is just the minus (-) character.
|
101 |
-
* Then comes the optional minimum field width modifier.
|
102 |
-
* This is a decimal constant that represents the minimum number of characters to output.
|
103 |
-
* If the data item requires fewer characters, it is padded on either the left or the right until the minimum width is reached. The default is to pad on the left (right justify) but you can specify right padding with the left justification flag. The padding character is space. If the data item is larger than the minimum field width, the field is expanded to accommodate the data.
|
104 |
-
* The value is never truncated.</p>
|
105 |
-
*
|
106 |
-
* <p>This behavior can be changed using the maximum field width modifier which is designated by a period
|
107 |
-
* followed by a decimal constant.
|
108 |
-
* If the data item is longer than the maximum field,
|
109 |
-
* then the extra characters are removed from the beginning of the data item and not from the end.
|
110 |
-
* For example, it the maximum field width is eight and the data item is ten characters long,
|
111 |
-
* then the first two characters of the data item are dropped.
|
112 |
-
* This behavior deviates from the printf function in C where truncation is done from the end.</p>
|
113 |
-
*
|
114 |
-
* <p>Below are various format modifier examples for the category conversion specifier.</p>
|
115 |
-
* <pre>
|
116 |
-
* Format modifier left justify minimum width maximum width comment
|
117 |
-
* %20c false 20 none Left pad with spaces if the category name
|
118 |
-
* is less than 20 characters long.
|
119 |
-
* %-20c true 20 none Right pad with spaces if the category name
|
120 |
-
* is less than 20 characters long.
|
121 |
-
* %.30c NA none 30 Truncate from the beginning if the category name
|
122 |
-
* is longer than 30 characters.
|
123 |
-
* %20.30c false 20 30 Left pad with spaces if the category name
|
124 |
-
* is shorter than 20 characters.
|
125 |
-
* However, if category name is longer than 30 chars,
|
126 |
-
* then truncate from the beginning.
|
127 |
-
* %-20.30c true 20 30 Right pad with spaces if the category name is
|
128 |
-
* shorter than 20 chars.
|
129 |
-
* However, if category name is longer than 30 chars,
|
130 |
-
* then truncate from the beginning.
|
131 |
-
* </pre>
|
132 |
-
*
|
133 |
-
* @version $Revision: 1213283 $
|
134 |
-
* @package log4php
|
135 |
-
* @subpackage layouts
|
136 |
-
* @since 0.3
|
137 |
-
*/
|
138 |
-
class LoggerLayoutPattern extends LoggerLayout {
|
139 |
-
/** Default conversion Pattern */
|
140 |
-
const DEFAULT_CONVERSION_PATTERN = '%m%n';
|
141 |
-
|
142 |
-
/** Default conversion TTCC Pattern */
|
143 |
-
const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
|
144 |
-
|
145 |
-
/** The conversion pattern. */
|
146 |
-
protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Head of a chain of Converters.
|
150 |
-
* @var LoggerPatternConverter
|
151 |
-
*/
|
152 |
-
private $head;
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Set the <b>ConversionPattern</b> option. This is the string which
|
156 |
-
* controls formatting and consists of a mix of literal content and
|
157 |
-
* conversion specifiers.
|
158 |
-
*/
|
159 |
-
public function setConversionPattern($conversionPattern) {
|
160 |
-
$this->pattern = $conversionPattern;
|
161 |
-
$patternParser = new LoggerPatternParser($this->pattern);
|
162 |
-
$this->head = $patternParser->parse();
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Produces a formatted string as specified by the conversion pattern.
|
167 |
-
*
|
168 |
-
* @param LoggerLoggingEvent $event
|
169 |
-
* @return string
|
170 |
-
*/
|
171 |
-
public function format(LoggerLoggingEvent $event) {
|
172 |
-
$sbuf = '';
|
173 |
-
$c = $this->head;
|
174 |
-
while ($c !== null) {
|
175 |
-
$c->format($sbuf, $event);
|
176 |
-
$c = $c->next;
|
177 |
-
}
|
178 |
-
return $sbuf;
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Returns an array with the formatted elements.
|
183 |
-
*
|
184 |
-
* This method is mainly used for the prepared statements of {@see LoggerAppenderPDO}.
|
185 |
-
*
|
186 |
-
* It requires {@link $this->pattern} to be a comma separated string of patterns like
|
187 |
-
* e.g. <code>%d,%c,%p,%m,%t,%F,%L</code>.
|
188 |
-
*
|
189 |
-
* @return array(string) An array of the converted elements i.e. timestamp, message, filename etc.
|
190 |
-
*/
|
191 |
-
public function formatToArray(LoggerLoggingEvent $event) {
|
192 |
-
$results = array();
|
193 |
-
$c = $this->head;
|
194 |
-
while ($c !== null) {
|
195 |
-
if ( ! $c instanceOf LoggerLiteralPatternConverter) {
|
196 |
-
$sbuf = null;
|
197 |
-
$c->format($sbuf, $event);
|
198 |
-
$results[] = $sbuf;
|
199 |
-
}
|
200 |
-
$c = $c->next;
|
201 |
-
}
|
202 |
-
return $results;
|
203 |
-
}
|
204 |
-
|
205 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/renderers/LoggerRendererMap.php
DELETED
@@ -1,149 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* Log objects using customized renderers that implement {@link LoggerRendererObject}.
|
23 |
-
*
|
24 |
-
* Example:
|
25 |
-
* {@example ../../examples/php/renderer_map.php 19}<br>
|
26 |
-
* {@example ../../examples/resources/renderer_map.properties 18}<br>
|
27 |
-
* <pre>
|
28 |
-
* DEBUG - Now comes the current MyClass object:
|
29 |
-
* DEBUG - Doe, John
|
30 |
-
* </pre>
|
31 |
-
*
|
32 |
-
* @version $Revision: 1166187 $
|
33 |
-
* @package log4php
|
34 |
-
* @subpackage renderers
|
35 |
-
* @since 0.3
|
36 |
-
*/
|
37 |
-
class LoggerRendererMap {
|
38 |
-
|
39 |
-
/**
|
40 |
-
* @var array
|
41 |
-
*/
|
42 |
-
private $map;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @var LoggerDefaultRenderer
|
46 |
-
*/
|
47 |
-
private $defaultRenderer;
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Constructor
|
51 |
-
*/
|
52 |
-
public function __construct() {
|
53 |
-
$this->map = array();
|
54 |
-
$this->defaultRenderer = new LoggerRendererDefault();
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Add a renderer to a hierarchy passed as parameter.
|
59 |
-
* Note that hierarchy must implement getRendererMap() and setRenderer() methods.
|
60 |
-
*
|
61 |
-
* @param LoggerHierarchy $repository a logger repository.
|
62 |
-
* @param string $renderedClassName
|
63 |
-
* @param string $renderingClassName
|
64 |
-
*/
|
65 |
-
public function addRenderer($renderedClassName, $renderingClassName) {
|
66 |
-
$renderer = LoggerReflectionUtils::createObject($renderingClassName);
|
67 |
-
if($renderer == null) {
|
68 |
-
return;
|
69 |
-
} else {
|
70 |
-
$this->put($renderedClassName, $renderer);
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Find the appropriate renderer for the class type of the
|
77 |
-
* <var>o</var> parameter.
|
78 |
-
*
|
79 |
-
* This is accomplished by calling the {@link getByObject()}
|
80 |
-
* method if <var>o</var> is object or using {@link LoggerRendererDefault}.
|
81 |
-
* Once a renderer is found, it is applied on the object <var>o</var> and
|
82 |
-
* the result is returned as a string.
|
83 |
-
*
|
84 |
-
* @param mixed $o
|
85 |
-
* @return string
|
86 |
-
*/
|
87 |
-
public function findAndRender($o) {
|
88 |
-
if($o == null) {
|
89 |
-
return null;
|
90 |
-
} else {
|
91 |
-
if(is_object($o)) {
|
92 |
-
$renderer = $this->getByObject($o);
|
93 |
-
if($renderer !== null) {
|
94 |
-
return $renderer->render($o);
|
95 |
-
} else {
|
96 |
-
return null;
|
97 |
-
}
|
98 |
-
} else {
|
99 |
-
$renderer = $this->defaultRenderer;
|
100 |
-
return $renderer->render($o);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
|
107 |
-
* class of the object parameter.
|
108 |
-
*
|
109 |
-
* @param mixed $o
|
110 |
-
* @return string
|
111 |
-
*/
|
112 |
-
public function getByObject($o) {
|
113 |
-
return ($o == null) ? null : $this->getByClassName(get_class($o));
|
114 |
-
}
|
115 |
-
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Search the parents of <var>clazz</var> for a renderer.
|
119 |
-
*
|
120 |
-
* The renderer closest in the hierarchy will be returned. If no
|
121 |
-
* renderers could be found, then the default renderer is returned.
|
122 |
-
*
|
123 |
-
* @param string $class
|
124 |
-
* @return LoggerRendererObject
|
125 |
-
*/
|
126 |
-
public function getByClassName($class) {
|
127 |
-
$r = null;
|
128 |
-
for($c = $class; !empty($c); $c = get_parent_class($c)) {
|
129 |
-
$c = strtolower($c);
|
130 |
-
if(isset($this->map[$c])) {
|
131 |
-
return $this->map[$c];
|
132 |
-
}
|
133 |
-
}
|
134 |
-
return $this->defaultRenderer;
|
135 |
-
}
|
136 |
-
|
137 |
-
public function clear() {
|
138 |
-
$this->map = array();
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Register a {@link LoggerRendererObject} for <var>clazz</var>.
|
143 |
-
* @param string $class
|
144 |
-
* @param LoggerRendererObject $or
|
145 |
-
*/
|
146 |
-
private function put($class, $or) {
|
147 |
-
$this->map[strtolower($class)] = $or;
|
148 |
-
}
|
149 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/renderers/LoggerRendererObject.php
DELETED
@@ -1,46 +0,0 @@
|
|
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 |
-
/**
|
22 |
-
* Implement this interface in order to render objects as strings using {@link LoggerRendererMap}.
|
23 |
-
*
|
24 |
-
* Implement this interface in order to render objects as strings using {@link LoggerRendererMap}.
|
25 |
-
*
|
26 |
-
* Example:
|
27 |
-
* {@example ../../examples/php/renderer_map.php 19}<br>
|
28 |
-
* {@example ../../examples/resources/renderer_map.properties 18}<br>
|
29 |
-
* <pre>
|
30 |
-
* DEBUG - Now comes the current MyClass object:
|
31 |
-
* DEBUG - Doe, John
|
32 |
-
* </pre>
|
33 |
-
*
|
34 |
-
* @version $Revision: 883108 $
|
35 |
-
* @package log4php
|
36 |
-
* @subpackage renderers
|
37 |
-
* @since 0.3
|
38 |
-
*/
|
39 |
-
interface LoggerRendererObject {
|
40 |
-
/**
|
41 |
-
* Render the entity passed as parameter as a String.
|
42 |
-
* @param mixed $o entity to render
|
43 |
-
* @return string
|
44 |
-
*/
|
45 |
-
public function render($o);
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/Logger.php
RENAMED
@@ -1,576 +1,596 @@
|
|
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 |
-
require dirname(__FILE__) . '/LoggerAutoloader.php';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* This is the central class in the log4php package. All logging operations
|
25 |
-
* are done through this class.
|
26 |
-
*
|
27 |
-
* The main logging methods are:
|
28 |
-
* <ul>
|
29 |
-
* <li>{@link trace()}</li>
|
30 |
-
* <li>{@link debug()}</li>
|
31 |
-
* <li>{@link info()}</li>
|
32 |
-
* <li>{@link warn()}</li>
|
33 |
-
* <li>{@link error()}</li>
|
34 |
-
* <li>{@link fatal()}</li>
|
35 |
-
* </ul>
|
36 |
-
*
|
37 |
-
* @package log4php
|
38 |
-
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
39 |
-
* @version SVN: $Id: Logger.php
|
40 |
-
* @link http://logging.apache.org/log4php
|
41 |
-
*/
|
42 |
-
class Logger {
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Logger additivity. If set to true then child loggers will inherit
|
46 |
-
* the appenders of their ancestors by default.
|
47 |
-
* @var boolean
|
48 |
-
*/
|
49 |
-
private $additive = true;
|
50 |
-
|
51 |
-
/**
|
52 |
-
* The Logger's fully qualified class name.
|
53 |
-
* TODO: Determine if this is useful.
|
54 |
-
*/
|
55 |
-
private $fqcn = 'Logger';
|
56 |
-
|
57 |
-
/** The assigned Logger level. */
|
58 |
-
private $level;
|
59 |
-
|
60 |
-
/** The name of this Logger instance. */
|
61 |
-
private $name;
|
62 |
-
|
63 |
-
/** The parent logger. Set to null if this is the root logger. */
|
64 |
-
private $parent;
|
65 |
-
|
66 |
-
/** A collection of appenders linked to this logger. */
|
67 |
-
private $appenders = array();
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Constructor.
|
71 |
-
* @param string $name Name of the logger.
|
72 |
-
*/
|
73 |
-
public function __construct($name) {
|
74 |
-
$this->name = $name;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Returns the logger name.
|
79 |
-
* @return string
|
80 |
-
*/
|
81 |
-
public function getName() {
|
82 |
-
return $this->name;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Returns the parent Logger. Can be null if this is the root logger.
|
87 |
-
* @return Logger
|
88 |
-
*/
|
89 |
-
public function getParent() {
|
90 |
-
return $this->parent;
|
91 |
-
}
|
92 |
-
|
93 |
-
// ******************************************
|
94 |
-
// *** Logging methods ***
|
95 |
-
// ******************************************
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Log a message object with the TRACE level.
|
99 |
-
*
|
100 |
-
* @param mixed $message message
|
101 |
-
* @param Exception $throwable Optional throwable information to include
|
102 |
-
* in the logging event.
|
103 |
-
*/
|
104 |
-
public function trace($message, $throwable = null) {
|
105 |
-
$this->log(LoggerLevel::getLevelTrace(), $message, $throwable);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Log a message object with the DEBUG level.
|
110 |
-
*
|
111 |
-
* @param mixed $message message
|
112 |
-
* @param Exception $throwable Optional throwable information to include
|
113 |
-
* in the logging event.
|
114 |
-
*/
|
115 |
-
public function debug($message, $throwable = null) {
|
116 |
-
$this->log(LoggerLevel::getLevelDebug(), $message, $throwable);
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Log a message object with the INFO Level.
|
121 |
-
*
|
122 |
-
* @param mixed $message message
|
123 |
-
* @param Exception $throwable Optional throwable information to include
|
124 |
-
* in the logging event.
|
125 |
-
*/
|
126 |
-
public function info($message, $throwable = null) {
|
127 |
-
$this->log(LoggerLevel::getLevelInfo(), $message, $throwable);
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Log a message with the WARN level.
|
132 |
-
*
|
133 |
-
* @param mixed $message message
|
134 |
-
* @param Exception $throwable Optional throwable information to include
|
135 |
-
* in the logging event.
|
136 |
-
*/
|
137 |
-
public function warn($message, $throwable = null) {
|
138 |
-
$this->log(LoggerLevel::getLevelWarn(), $message, $throwable);
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Log a message object with the ERROR level.
|
143 |
-
*
|
144 |
-
* @param mixed $message message
|
145 |
-
* @param Exception $throwable Optional throwable information to include
|
146 |
-
* in the logging event.
|
147 |
-
*/
|
148 |
-
public function error($message, $throwable = null) {
|
149 |
-
$this->log(LoggerLevel::getLevelError(), $message, $throwable);
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Log a message object with the FATAL level.
|
154 |
-
*
|
155 |
-
* @param mixed $message message
|
156 |
-
* @param Exception $throwable Optional throwable information to include
|
157 |
-
* in the logging event.
|
158 |
-
*/
|
159 |
-
public function fatal($message, $throwable = null) {
|
160 |
-
$this->log(LoggerLevel::getLevelFatal(), $message, $throwable);
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Log a message using the provided logging level.
|
165 |
-
*
|
166 |
-
* @param LoggerLevel $level The logging level.
|
167 |
-
* @param mixed $message Message to log.
|
168 |
-
* @param Exception $throwable Optional throwable information to include
|
169 |
-
* in the logging event.
|
170 |
-
*/
|
171 |
-
public function log(LoggerLevel $level, $message, $throwable = null) {
|
172 |
-
if($this->isEnabledFor($level)) {
|
173 |
-
$
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
*
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
*
|
219 |
-
*
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
*
|
227 |
-
*
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
*
|
243 |
-
* @
|
244 |
-
*/
|
245 |
-
public function
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
*
|
259 |
-
* @return boolean
|
260 |
-
*/
|
261 |
-
public function
|
262 |
-
return $this->
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Check whether this Logger is enabled for the
|
267 |
-
* @return boolean
|
268 |
-
*/
|
269 |
-
public function
|
270 |
-
return $this->isEnabledFor(LoggerLevel::
|
271 |
-
}
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
public function
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
}
|
346 |
-
|
347 |
-
/**
|
348 |
-
* Returns the
|
349 |
-
* @return
|
350 |
-
*/
|
351 |
-
public function
|
352 |
-
return $this->
|
353 |
-
}
|
354 |
-
|
355 |
-
/**
|
356 |
-
*
|
357 |
-
* @
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
*
|
416 |
-
*
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
}
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
*
|
445 |
-
*
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
self::getHierarchy()->
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
return self::getHierarchy()->
|
478 |
-
}
|
479 |
-
|
480 |
-
/**
|
481 |
-
*
|
482 |
-
*
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
*
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
*
|
508 |
-
*
|
509 |
-
* @param string
|
510 |
-
*
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
*
|
527 |
-
*
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
require dirname(__FILE__) . '/LoggerAutoloader.php';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* This is the central class in the log4php package. All logging operations
|
25 |
+
* are done through this class.
|
26 |
+
*
|
27 |
+
* The main logging methods are:
|
28 |
+
* <ul>
|
29 |
+
* <li>{@link trace()}</li>
|
30 |
+
* <li>{@link debug()}</li>
|
31 |
+
* <li>{@link info()}</li>
|
32 |
+
* <li>{@link warn()}</li>
|
33 |
+
* <li>{@link error()}</li>
|
34 |
+
* <li>{@link fatal()}</li>
|
35 |
+
* </ul>
|
36 |
+
*
|
37 |
+
* @package log4php
|
38 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
39 |
+
* @version SVN: $Id: Logger.php 1395241 2012-10-07 08:28:53Z ihabunek $
|
40 |
+
* @link http://logging.apache.org/log4php
|
41 |
+
*/
|
42 |
+
class Logger {
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Logger additivity. If set to true then child loggers will inherit
|
46 |
+
* the appenders of their ancestors by default.
|
47 |
+
* @var boolean
|
48 |
+
*/
|
49 |
+
private $additive = true;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The Logger's fully qualified class name.
|
53 |
+
* TODO: Determine if this is useful.
|
54 |
+
*/
|
55 |
+
private $fqcn = 'Logger';
|
56 |
+
|
57 |
+
/** The assigned Logger level. */
|
58 |
+
private $level;
|
59 |
+
|
60 |
+
/** The name of this Logger instance. */
|
61 |
+
private $name;
|
62 |
+
|
63 |
+
/** The parent logger. Set to null if this is the root logger. */
|
64 |
+
private $parent;
|
65 |
+
|
66 |
+
/** A collection of appenders linked to this logger. */
|
67 |
+
private $appenders = array();
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Constructor.
|
71 |
+
* @param string $name Name of the logger.
|
72 |
+
*/
|
73 |
+
public function __construct($name) {
|
74 |
+
$this->name = $name;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Returns the logger name.
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function getName() {
|
82 |
+
return $this->name;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Returns the parent Logger. Can be null if this is the root logger.
|
87 |
+
* @return Logger
|
88 |
+
*/
|
89 |
+
public function getParent() {
|
90 |
+
return $this->parent;
|
91 |
+
}
|
92 |
+
|
93 |
+
// ******************************************
|
94 |
+
// *** Logging methods ***
|
95 |
+
// ******************************************
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Log a message object with the TRACE level.
|
99 |
+
*
|
100 |
+
* @param mixed $message message
|
101 |
+
* @param Exception $throwable Optional throwable information to include
|
102 |
+
* in the logging event.
|
103 |
+
*/
|
104 |
+
public function trace($message, $throwable = null) {
|
105 |
+
$this->log(LoggerLevel::getLevelTrace(), $message, $throwable);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Log a message object with the DEBUG level.
|
110 |
+
*
|
111 |
+
* @param mixed $message message
|
112 |
+
* @param Exception $throwable Optional throwable information to include
|
113 |
+
* in the logging event.
|
114 |
+
*/
|
115 |
+
public function debug($message, $throwable = null) {
|
116 |
+
$this->log(LoggerLevel::getLevelDebug(), $message, $throwable);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Log a message object with the INFO Level.
|
121 |
+
*
|
122 |
+
* @param mixed $message message
|
123 |
+
* @param Exception $throwable Optional throwable information to include
|
124 |
+
* in the logging event.
|
125 |
+
*/
|
126 |
+
public function info($message, $throwable = null) {
|
127 |
+
$this->log(LoggerLevel::getLevelInfo(), $message, $throwable);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Log a message with the WARN level.
|
132 |
+
*
|
133 |
+
* @param mixed $message message
|
134 |
+
* @param Exception $throwable Optional throwable information to include
|
135 |
+
* in the logging event.
|
136 |
+
*/
|
137 |
+
public function warn($message, $throwable = null) {
|
138 |
+
$this->log(LoggerLevel::getLevelWarn(), $message, $throwable);
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Log a message object with the ERROR level.
|
143 |
+
*
|
144 |
+
* @param mixed $message message
|
145 |
+
* @param Exception $throwable Optional throwable information to include
|
146 |
+
* in the logging event.
|
147 |
+
*/
|
148 |
+
public function error($message, $throwable = null) {
|
149 |
+
$this->log(LoggerLevel::getLevelError(), $message, $throwable);
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Log a message object with the FATAL level.
|
154 |
+
*
|
155 |
+
* @param mixed $message message
|
156 |
+
* @param Exception $throwable Optional throwable information to include
|
157 |
+
* in the logging event.
|
158 |
+
*/
|
159 |
+
public function fatal($message, $throwable = null) {
|
160 |
+
$this->log(LoggerLevel::getLevelFatal(), $message, $throwable);
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Log a message using the provided logging level.
|
165 |
+
*
|
166 |
+
* @param LoggerLevel $level The logging level.
|
167 |
+
* @param mixed $message Message to log.
|
168 |
+
* @param Exception $throwable Optional throwable information to include
|
169 |
+
* in the logging event.
|
170 |
+
*/
|
171 |
+
public function log(LoggerLevel $level, $message, $throwable = null) {
|
172 |
+
if($this->isEnabledFor($level)) {
|
173 |
+
$event = new LoggerLoggingEvent($this->fqcn, $this, $level, $message, null, $throwable);
|
174 |
+
$this->callAppenders($event);
|
175 |
+
}
|
176 |
+
|
177 |
+
// Forward the event upstream if additivity is turned on
|
178 |
+
if(isset($this->parent) && $this->getAdditivity()) {
|
179 |
+
|
180 |
+
// Use the event if already created
|
181 |
+
if (isset($event)) {
|
182 |
+
$this->parent->logEvent($event);
|
183 |
+
} else {
|
184 |
+
$this->parent->log($level, $message, $throwable);
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Logs an already prepared logging event object.
|
191 |
+
* @param LoggerLoggingEvent $event
|
192 |
+
*/
|
193 |
+
public function logEvent(LoggerLoggingEvent $event) {
|
194 |
+
if($this->isEnabledFor($event->getLevel())) {
|
195 |
+
$this->callAppenders($event);
|
196 |
+
}
|
197 |
+
|
198 |
+
// Forward the event upstream if additivity is turned on
|
199 |
+
if(isset($this->parent) && $this->getAdditivity()) {
|
200 |
+
$this->parent->logEvent($event);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* If assertion parameter evaluates as false, then logs the message
|
206 |
+
* using the ERROR level.
|
207 |
+
*
|
208 |
+
* @param bool $assertion
|
209 |
+
* @param string $msg message to log
|
210 |
+
*/
|
211 |
+
public function assertLog($assertion = true, $msg = '') {
|
212 |
+
if($assertion == false) {
|
213 |
+
$this->error($msg);
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* This method creates a new logging event and logs the event without
|
219 |
+
* further checks.
|
220 |
+
*
|
221 |
+
* It should not be called directly. Use {@link trace()}, {@link debug()},
|
222 |
+
* {@link info()}, {@link warn()}, {@link error()} and {@link fatal()}
|
223 |
+
* wrappers.
|
224 |
+
*
|
225 |
+
* @param string $fqcn Fully qualified class name of the Logger
|
226 |
+
* @param Exception $throwable Optional throwable information to include
|
227 |
+
* in the logging event.
|
228 |
+
* @param LoggerLevel $level log level
|
229 |
+
* @param mixed $message message to log
|
230 |
+
*/
|
231 |
+
public function forcedLog($fqcn, $throwable, LoggerLevel $level, $message) {
|
232 |
+
$event = new LoggerLoggingEvent($fqcn, $this, $level, $message, null, $throwable);
|
233 |
+
$this->callAppenders($event);
|
234 |
+
|
235 |
+
// Forward the event upstream if additivity is turned on
|
236 |
+
if(isset($this->parent) && $this->getAdditivity()) {
|
237 |
+
$this->parent->logEvent($event);
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Forwards the given logging event to all linked appenders.
|
243 |
+
* @param LoggerLoggingEvent $event
|
244 |
+
*/
|
245 |
+
public function callAppenders($event) {
|
246 |
+
foreach($this->appenders as $appender) {
|
247 |
+
$appender->doAppend($event);
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
// ******************************************
|
252 |
+
// *** Checker methods ***
|
253 |
+
// ******************************************
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Check whether this Logger is enabled for a given Level passed as parameter.
|
257 |
+
*
|
258 |
+
* @param LoggerLevel level
|
259 |
+
* @return boolean
|
260 |
+
*/
|
261 |
+
public function isEnabledFor(LoggerLevel $level) {
|
262 |
+
return $level->isGreaterOrEqual($this->getEffectiveLevel());
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Check whether this Logger is enabled for the TRACE Level.
|
267 |
+
* @return boolean
|
268 |
+
*/
|
269 |
+
public function isTraceEnabled() {
|
270 |
+
return $this->isEnabledFor(LoggerLevel::getLevelTrace());
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Check whether this Logger is enabled for the DEBUG Level.
|
275 |
+
* @return boolean
|
276 |
+
*/
|
277 |
+
public function isDebugEnabled() {
|
278 |
+
return $this->isEnabledFor(LoggerLevel::getLevelDebug());
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Check whether this Logger is enabled for the INFO Level.
|
283 |
+
* @return boolean
|
284 |
+
*/
|
285 |
+
public function isInfoEnabled() {
|
286 |
+
return $this->isEnabledFor(LoggerLevel::getLevelInfo());
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Check whether this Logger is enabled for the WARN Level.
|
291 |
+
* @return boolean
|
292 |
+
*/
|
293 |
+
public function isWarnEnabled() {
|
294 |
+
return $this->isEnabledFor(LoggerLevel::getLevelWarn());
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Check whether this Logger is enabled for the ERROR Level.
|
299 |
+
* @return boolean
|
300 |
+
*/
|
301 |
+
public function isErrorEnabled() {
|
302 |
+
return $this->isEnabledFor(LoggerLevel::getLevelError());
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Check whether this Logger is enabled for the FATAL Level.
|
307 |
+
* @return boolean
|
308 |
+
*/
|
309 |
+
public function isFatalEnabled() {
|
310 |
+
return $this->isEnabledFor(LoggerLevel::getLevelFatal());
|
311 |
+
}
|
312 |
+
|
313 |
+
// ******************************************
|
314 |
+
// *** Configuration methods ***
|
315 |
+
// ******************************************
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Adds a new appender to the Logger.
|
319 |
+
* @param LoggerAppender $appender The appender to add.
|
320 |
+
*/
|
321 |
+
public function addAppender($appender) {
|
322 |
+
$appenderName = $appender->getName();
|
323 |
+
$this->appenders[$appenderName] = $appender;
|
324 |
+
}
|
325 |
+
|
326 |
+
/** Removes all appenders from the Logger. */
|
327 |
+
public function removeAllAppenders() {
|
328 |
+
foreach($this->appenders as $name => $appender) {
|
329 |
+
$this->removeAppender($name);
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Remove the appender passed as parameter form the Logger.
|
335 |
+
* @param mixed $appender an appender name or a {@link LoggerAppender} instance.
|
336 |
+
*/
|
337 |
+
public function removeAppender($appender) {
|
338 |
+
if($appender instanceof LoggerAppender) {
|
339 |
+
$appender->close();
|
340 |
+
unset($this->appenders[$appender->getName()]);
|
341 |
+
} else if (is_string($appender) and isset($this->appenders[$appender])) {
|
342 |
+
$this->appenders[$appender]->close();
|
343 |
+
unset($this->appenders[$appender]);
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Returns the appenders linked to this logger as an array.
|
349 |
+
* @return array collection of appender names
|
350 |
+
*/
|
351 |
+
public function getAllAppenders() {
|
352 |
+
return $this->appenders;
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Returns a linked appender by name.
|
357 |
+
* @return LoggerAppender
|
358 |
+
*/
|
359 |
+
public function getAppender($name) {
|
360 |
+
return $this->appenders[$name];
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Sets the additivity flag.
|
365 |
+
* @param boolean $additive
|
366 |
+
*/
|
367 |
+
public function setAdditivity($additive) {
|
368 |
+
$this->additive = (bool)$additive;
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Returns the additivity flag.
|
373 |
+
* @return boolean
|
374 |
+
*/
|
375 |
+
public function getAdditivity() {
|
376 |
+
return $this->additive;
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Starting from this Logger, search the Logger hierarchy for a non-null level and return it.
|
381 |
+
* @see LoggerLevel
|
382 |
+
* @return LoggerLevel or null
|
383 |
+
*/
|
384 |
+
public function getEffectiveLevel() {
|
385 |
+
for($logger = $this; $logger !== null; $logger = $logger->getParent()) {
|
386 |
+
if($logger->getLevel() !== null) {
|
387 |
+
return $logger->getLevel();
|
388 |
+
}
|
389 |
+
}
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Get the assigned Logger level.
|
394 |
+
* @return LoggerLevel The assigned level or null if none is assigned.
|
395 |
+
*/
|
396 |
+
public function getLevel() {
|
397 |
+
return $this->level;
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* Set the Logger level.
|
402 |
+
*
|
403 |
+
* Use LoggerLevel::getLevelXXX() methods to get a LoggerLevel object, e.g.
|
404 |
+
* <code>$logger->setLevel(LoggerLevel::getLevelInfo());</code>
|
405 |
+
*
|
406 |
+
* @param LoggerLevel $level The level to set, or NULL to clear the logger level.
|
407 |
+
*/
|
408 |
+
public function setLevel(LoggerLevel $level = null) {
|
409 |
+
$this->level = $level;
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Checks whether an appender is attached to this logger instance.
|
414 |
+
*
|
415 |
+
* @param LoggerAppender $appender
|
416 |
+
* @return boolean
|
417 |
+
*/
|
418 |
+
public function isAttached(LoggerAppender $appender) {
|
419 |
+
return isset($this->appenders[$appender->getName()]);
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Sets the parent logger.
|
424 |
+
* @param Logger $logger
|
425 |
+
*/
|
426 |
+
public function setParent(Logger $logger) {
|
427 |
+
$this->parent = $logger;
|
428 |
+
}
|
429 |
+
|
430 |
+
// ******************************************
|
431 |
+
// *** Static methods and properties ***
|
432 |
+
// ******************************************
|
433 |
+
|
434 |
+
/** The logger hierarchy used by log4php. */
|
435 |
+
private static $hierarchy;
|
436 |
+
|
437 |
+
/** Inidicates if log4php has been initialized */
|
438 |
+
private static $initialized = false;
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Returns the hierarchy used by this Logger.
|
442 |
+
*
|
443 |
+
* Caution: do not use this hierarchy unless you have called initialize().
|
444 |
+
* To get Loggers, use the Logger::getLogger and Logger::getRootLogger
|
445 |
+
* methods instead of operating on on the hierarchy directly.
|
446 |
+
*
|
447 |
+
* @return LoggerHierarchy
|
448 |
+
*/
|
449 |
+
public static function getHierarchy() {
|
450 |
+
if(!isset(self::$hierarchy)) {
|
451 |
+
self::$hierarchy = new LoggerHierarchy(new LoggerRoot());
|
452 |
+
}
|
453 |
+
return self::$hierarchy;
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Returns a Logger by name. If it does not exist, it will be created.
|
458 |
+
*
|
459 |
+
* @param string $name The logger name
|
460 |
+
* @return Logger
|
461 |
+
*/
|
462 |
+
public static function getLogger($name) {
|
463 |
+
if(!self::isInitialized()) {
|
464 |
+
self::configure();
|
465 |
+
}
|
466 |
+
return self::getHierarchy()->getLogger($name);
|
467 |
+
}
|
468 |
+
|
469 |
+
/**
|
470 |
+
* Returns the Root Logger.
|
471 |
+
* @return LoggerRoot
|
472 |
+
*/
|
473 |
+
public static function getRootLogger() {
|
474 |
+
if(!self::isInitialized()) {
|
475 |
+
self::configure();
|
476 |
+
}
|
477 |
+
return self::getHierarchy()->getRootLogger();
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Clears all Logger definitions from the logger hierarchy.
|
482 |
+
* @return boolean
|
483 |
+
*/
|
484 |
+
public static function clear() {
|
485 |
+
return self::getHierarchy()->clear();
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Destroy configurations for logger definitions
|
490 |
+
*/
|
491 |
+
public static function resetConfiguration() {
|
492 |
+
self::getHierarchy()->resetConfiguration();
|
493 |
+
self::getHierarchy()->clear(); // TODO: clear or not?
|
494 |
+
self::$initialized = false;
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* Safely close all appenders.
|
499 |
+
* @deprecated This is no longer necessary due the appenders shutdown via
|
500 |
+
* destructors.
|
501 |
+
*/
|
502 |
+
public static function shutdown() {
|
503 |
+
return self::getHierarchy()->shutdown();
|
504 |
+
}
|
505 |
+
|
506 |
+
/**
|
507 |
+
* check if a given logger exists.
|
508 |
+
*
|
509 |
+
* @param string $name logger name
|
510 |
+
* @return boolean
|
511 |
+
*/
|
512 |
+
public static function exists($name) {
|
513 |
+
return self::getHierarchy()->exists($name);
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Returns an array this whole Logger instances.
|
518 |
+
* @see Logger
|
519 |
+
* @return array
|
520 |
+
*/
|
521 |
+
public static function getCurrentLoggers() {
|
522 |
+
return self::getHierarchy()->getCurrentLoggers();
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Configures log4php.
|
527 |
+
*
|
528 |
+
* This method needs to be called before the first logging event has
|
529 |
+
* occured. If this method is not called before then the default
|
530 |
+
* configuration will be used.
|
531 |
+
*
|
532 |
+
* @param string|array $configuration Either a path to the configuration
|
533 |
+
* file, or a configuration array.
|
534 |
+
*
|
535 |
+
* @param string|LoggerConfigurator $configurator A custom
|
536 |
+
* configurator class: either a class name (string), or an object which
|
537 |
+
* implements the LoggerConfigurator interface. If left empty, the default
|
538 |
+
* configurator implementation will be used.
|
539 |
+
*/
|
540 |
+
public static function configure($configuration = null, $configurator = null) {
|
541 |
+
self::resetConfiguration();
|
542 |
+
$configurator = self::getConfigurator($configurator);
|
543 |
+
$configurator->configure(self::getHierarchy(), $configuration);
|
544 |
+
self::$initialized = true;
|
545 |
+
}
|
546 |
+
|
547 |
+
/**
|
548 |
+
* Creates a logger configurator instance based on the provided
|
549 |
+
* configurator class. If no class is given, returns an instance of
|
550 |
+
* the default configurator.
|
551 |
+
*
|
552 |
+
* @param string|LoggerConfigurator $configurator The configurator class
|
553 |
+
* or LoggerConfigurator instance.
|
554 |
+
*/
|
555 |
+
private static function getConfigurator($configurator = null) {
|
556 |
+
if ($configurator === null) {
|
557 |
+
return new LoggerConfiguratorDefault();
|
558 |
+
}
|
559 |
+
|
560 |
+
if (is_object($configurator)) {
|
561 |
+
if ($configurator instanceof LoggerConfigurator) {
|
562 |
+
return $configurator;
|
563 |
+
} else {
|
564 |
+
trigger_error("log4php: Given configurator object [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING);
|
565 |
+
return new LoggerConfiguratorDefault();
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
if (is_string($configurator)) {
|
570 |
+
if (!class_exists($configurator)) {
|
571 |
+
trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING);
|
572 |
+
return new LoggerConfiguratorDefault();
|
573 |
+
}
|
574 |
+
|
575 |
+
$instance = new $configurator();
|
576 |
+
|
577 |
+
if (!($instance instanceof LoggerConfigurator)) {
|
578 |
+
trigger_error("log4php: Specified configurator class [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING);
|
579 |
+
return new LoggerConfiguratorDefault();
|
580 |
+
}
|
581 |
+
|
582 |
+
return $instance;
|
583 |
+
}
|
584 |
+
|
585 |
+
trigger_error("log4php: Invalid configurator specified. Expected either a string or a LoggerConfigurator instance. Reverting to default configurator.", E_USER_WARNING);
|
586 |
+
return new LoggerConfiguratorDefault();
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* Returns true if the log4php framework has been initialized.
|
591 |
+
* @return boolean
|
592 |
+
*/
|
593 |
+
private static function isInitialized() {
|
594 |
+
return self::$initialized;
|
595 |
+
}
|
596 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerAppender.php
RENAMED
@@ -1,287 +1,286 @@
|
|
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 |
-
/**
|
22 |
-
* Abstract class that defines output logs strategies.
|
23 |
-
*
|
24 |
-
* @version $Revision:
|
25 |
-
* @package log4php
|
26 |
-
*/
|
27 |
-
abstract class LoggerAppender extends LoggerConfigurable {
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Set to true when the appender is closed. A closed appender will not
|
31 |
-
* accept any logging requests.
|
32 |
-
* @var boolean
|
33 |
-
*/
|
34 |
-
protected $closed = false;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* The first filter in the filter chain.
|
38 |
-
* @var LoggerFilter
|
39 |
-
*/
|
40 |
-
protected $filter;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* The appender's layout. Can be null if the appender does not use
|
44 |
-
* a layout.
|
45 |
-
* @var LoggerLayout
|
46 |
-
*/
|
47 |
-
protected $layout;
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Appender name. Used by other components to identify this appender.
|
51 |
-
* @var string
|
52 |
-
*/
|
53 |
-
protected $name;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Appender threshold level. Events whose level is below the threshold
|
57 |
-
* will not be logged.
|
58 |
-
* @var LoggerLevel
|
59 |
-
*/
|
60 |
-
protected $threshold;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Set to true if the appender requires a layout.
|
64 |
-
*
|
65 |
-
* True by default, appenders which do not use a layout should override
|
66 |
-
* this property to false.
|
67 |
-
*
|
68 |
-
* @var boolean
|
69 |
-
*/
|
70 |
-
protected $requiresLayout = true;
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Default constructor.
|
74 |
-
* @param string $name Appender name
|
75 |
-
*/
|
76 |
-
public function __construct($name = '') {
|
77 |
-
$this->name = $name;
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Returns the default layout for this appender. Can be overriden by
|
90 |
-
* derived appenders.
|
91 |
-
*
|
92 |
-
* @return LoggerLayout
|
93 |
-
*/
|
94 |
-
public function getDefaultLayout()
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
*
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
*
|
120 |
-
*
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
*
|
129 |
-
*
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
*
|
138 |
-
*
|
139 |
-
* @
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
case LoggerFilter::
|
155 |
-
case LoggerFilter::
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
*
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
*
|
182 |
-
*
|
183 |
-
*
|
184 |
-
*
|
185 |
-
*
|
186 |
-
*
|
187 |
-
*
|
188 |
-
*
|
189 |
-
*
|
190 |
-
*
|
191 |
-
*
|
192 |
-
*
|
193 |
-
*
|
194 |
-
*
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
*
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
*
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
*
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
*
|
227 |
-
*
|
228 |
-
*
|
229 |
-
*
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
*
|
238 |
-
*
|
239 |
-
*
|
240 |
-
*
|
241 |
-
* @
|
242 |
-
*
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
*
|
254 |
-
*
|
255 |
-
*
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
*
|
264 |
-
*
|
265 |
-
*
|
266 |
-
*
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
*
|
273 |
-
*
|
274 |
-
*
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
}
|
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 |
+
/**
|
22 |
+
* Abstract class that defines output logs strategies.
|
23 |
+
*
|
24 |
+
* @version $Revision: 1374777 $
|
25 |
+
* @package log4php
|
26 |
+
*/
|
27 |
+
abstract class LoggerAppender extends LoggerConfigurable {
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Set to true when the appender is closed. A closed appender will not
|
31 |
+
* accept any logging requests.
|
32 |
+
* @var boolean
|
33 |
+
*/
|
34 |
+
protected $closed = false;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* The first filter in the filter chain.
|
38 |
+
* @var LoggerFilter
|
39 |
+
*/
|
40 |
+
protected $filter;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* The appender's layout. Can be null if the appender does not use
|
44 |
+
* a layout.
|
45 |
+
* @var LoggerLayout
|
46 |
+
*/
|
47 |
+
protected $layout;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Appender name. Used by other components to identify this appender.
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
+
protected $name;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Appender threshold level. Events whose level is below the threshold
|
57 |
+
* will not be logged.
|
58 |
+
* @var LoggerLevel
|
59 |
+
*/
|
60 |
+
protected $threshold;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Set to true if the appender requires a layout.
|
64 |
+
*
|
65 |
+
* True by default, appenders which do not use a layout should override
|
66 |
+
* this property to false.
|
67 |
+
*
|
68 |
+
* @var boolean
|
69 |
+
*/
|
70 |
+
protected $requiresLayout = true;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Default constructor.
|
74 |
+
* @param string $name Appender name
|
75 |
+
*/
|
76 |
+
public function __construct($name = '') {
|
77 |
+
$this->name = $name;
|
78 |
+
|
79 |
+
if ($this->requiresLayout) {
|
80 |
+
$this->layout = $this->getDefaultLayout();
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
public function __destruct() {
|
85 |
+
$this->close();
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns the default layout for this appender. Can be overriden by
|
90 |
+
* derived appenders.
|
91 |
+
*
|
92 |
+
* @return LoggerLayout
|
93 |
+
*/
|
94 |
+
public function getDefaultLayout() {
|
95 |
+
return new LoggerLayoutSimple();
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Adds a filter to the end of the filter chain.
|
100 |
+
* @param LoggerFilter $filter add a new LoggerFilter
|
101 |
+
*/
|
102 |
+
public function addFilter($filter) {
|
103 |
+
if($this->filter === null) {
|
104 |
+
$this->filter = $filter;
|
105 |
+
} else {
|
106 |
+
$this->filter->addNext($filter);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Clears the filter chain by removing all the filters in it.
|
112 |
+
*/
|
113 |
+
public function clearFilters() {
|
114 |
+
$this->filter = null;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Returns the first filter in the filter chain.
|
119 |
+
* The return value may be <i>null</i> if no is filter is set.
|
120 |
+
* @return LoggerFilter
|
121 |
+
*/
|
122 |
+
public function getFilter() {
|
123 |
+
return $this->filter;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Returns the first filter in the filter chain.
|
128 |
+
* The return value may be <i>null</i> if no is filter is set.
|
129 |
+
* @return LoggerFilter
|
130 |
+
*/
|
131 |
+
public function getFirstFilter() {
|
132 |
+
return $this->filter;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Performs threshold checks and invokes filters before delegating logging
|
137 |
+
* to the subclass' specific <i>append()</i> method.
|
138 |
+
* @see LoggerAppender::append()
|
139 |
+
* @param LoggerLoggingEvent $event
|
140 |
+
*/
|
141 |
+
public function doAppend(LoggerLoggingEvent $event) {
|
142 |
+
if($this->closed) {
|
143 |
+
return;
|
144 |
+
}
|
145 |
+
|
146 |
+
if(!$this->isAsSevereAsThreshold($event->getLevel())) {
|
147 |
+
return;
|
148 |
+
}
|
149 |
+
|
150 |
+
$filter = $this->getFirstFilter();
|
151 |
+
while($filter !== null) {
|
152 |
+
switch ($filter->decide($event)) {
|
153 |
+
case LoggerFilter::DENY: return;
|
154 |
+
case LoggerFilter::ACCEPT: return $this->append($event);
|
155 |
+
case LoggerFilter::NEUTRAL: $filter = $filter->getNext();
|
156 |
+
}
|
157 |
+
}
|
158 |
+
$this->append($event);
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Sets the appender layout.
|
163 |
+
* @param LoggerLayout $layout
|
164 |
+
*/
|
165 |
+
public function setLayout($layout) {
|
166 |
+
if($this->requiresLayout()) {
|
167 |
+
$this->layout = $layout;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Returns the appender layout.
|
173 |
+
* @return LoggerLayout
|
174 |
+
*/
|
175 |
+
public function getLayout() {
|
176 |
+
return $this->layout;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Configurators call this method to determine if the appender
|
181 |
+
* requires a layout.
|
182 |
+
*
|
183 |
+
* <p>If this method returns <i>true</i>, meaning that layout is required,
|
184 |
+
* then the configurator will configure a layout using the configuration
|
185 |
+
* information at its disposal. If this method returns <i>false</i>,
|
186 |
+
* meaning that a layout is not required, then layout configuration will be
|
187 |
+
* skipped even if there is available layout configuration
|
188 |
+
* information at the disposal of the configurator.</p>
|
189 |
+
*
|
190 |
+
* <p>In the rather exceptional case, where the appender
|
191 |
+
* implementation admits a layout but can also work without it, then
|
192 |
+
* the appender should return <i>true</i>.</p>
|
193 |
+
*
|
194 |
+
* @return boolean
|
195 |
+
*/
|
196 |
+
public function requiresLayout() {
|
197 |
+
return $this->requiresLayout;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Retruns the appender name.
|
202 |
+
* @return string
|
203 |
+
*/
|
204 |
+
public function getName() {
|
205 |
+
return $this->name;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Sets the appender name.
|
210 |
+
* @param string $name
|
211 |
+
*/
|
212 |
+
public function setName($name) {
|
213 |
+
$this->name = $name;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Returns the appender's threshold level.
|
218 |
+
* @return LoggerLevel
|
219 |
+
*/
|
220 |
+
public function getThreshold() {
|
221 |
+
return $this->threshold;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Sets the appender threshold.
|
226 |
+
*
|
227 |
+
* @param LoggerLevel|string $threshold Either a {@link LoggerLevel}
|
228 |
+
* object or a string equivalent.
|
229 |
+
* @see LoggerOptionConverter::toLevel()
|
230 |
+
*/
|
231 |
+
public function setThreshold($threshold) {
|
232 |
+
$this->setLevel('threshold', $threshold);
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Checks whether the message level is below the appender's threshold.
|
237 |
+
*
|
238 |
+
* If there is no threshold set, then the return value is always <i>true</i>.
|
239 |
+
*
|
240 |
+
* @param LoggerLevel $level
|
241 |
+
* @return boolean Returns true if level is greater or equal than
|
242 |
+
* threshold, or if the threshold is not set. Otherwise returns false.
|
243 |
+
*/
|
244 |
+
public function isAsSevereAsThreshold($level) {
|
245 |
+
if($this->threshold === null) {
|
246 |
+
return true;
|
247 |
+
}
|
248 |
+
return $level->isGreaterOrEqual($this->getThreshold());
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Prepares the appender for logging.
|
253 |
+
*
|
254 |
+
* Derived appenders should override this method if option structure
|
255 |
+
* requires it.
|
256 |
+
*/
|
257 |
+
public function activateOptions() {
|
258 |
+
$this->closed = false;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Forwards the logging event to the destination.
|
263 |
+
*
|
264 |
+
* Derived appenders should implement this method to perform actual logging.
|
265 |
+
*
|
266 |
+
* @param LoggerLoggingEvent $event
|
267 |
+
*/
|
268 |
+
abstract protected function append(LoggerLoggingEvent $event);
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Releases any resources allocated by the appender.
|
272 |
+
*
|
273 |
+
* Derived appenders should override this method to perform proper closing
|
274 |
+
* procedures.
|
275 |
+
*/
|
276 |
+
public function close() {
|
277 |
+
$this->closed = true;
|
278 |
+
}
|
279 |
+
|
280 |
+
/** Triggers a warning for this logger with the given message. */
|
281 |
+
protected function warn($message) {
|
282 |
+
$id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}");
|
283 |
+
trigger_error("log4php: [$id]: $message", E_USER_WARNING);
|
284 |
+
}
|
285 |
+
|
286 |
+
}
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerAppenderPool.php
RENAMED
@@ -26,7 +26,7 @@
|
|
26 |
* appender can be linked to multiple loggers. This makes sure duplicate
|
27 |
* appenders are not created.
|
28 |
*
|
29 |
-
* @version $Revision:
|
30 |
* @package log4php
|
31 |
*/
|
32 |
class LoggerAppenderPool {
|
@@ -39,8 +39,7 @@ class LoggerAppenderPool {
|
|
39 |
* The appender must be named for this operation.
|
40 |
* @param LoggerAppender $appender
|
41 |
*/
|
42 |
-
public static function add(LoggerAppender $appender)
|
43 |
-
{
|
44 |
$name = $appender->getName();
|
45 |
|
46 |
if(empty($name)) {
|
26 |
* appender can be linked to multiple loggers. This makes sure duplicate
|
27 |
* appenders are not created.
|
28 |
*
|
29 |
+
* @version $Revision: 1350602 $
|
30 |
* @package log4php
|
31 |
*/
|
32 |
class LoggerAppenderPool {
|
39 |
* The appender must be named for this operation.
|
40 |
* @param LoggerAppender $appender
|
41 |
*/
|
42 |
+
public static function add(LoggerAppender $appender) {
|
|
|
43 |
$name = $appender->getName();
|
44 |
|
45 |
if(empty($name)) {
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerAutoloader.php
RENAMED
@@ -21,7 +21,7 @@
|
|
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 |
/**
|
@@ -29,7 +29,7 @@
|
|
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 |
|
@@ -42,6 +42,7 @@ class LoggerAutoloader {
|
|
42 |
'LoggerConfigurable' => '/LoggerConfigurable.php',
|
43 |
'LoggerConfigurator' => '/LoggerConfigurator.php',
|
44 |
'LoggerException' => '/LoggerException.php',
|
|
|
45 |
'LoggerHierarchy' => '/LoggerHierarchy.php',
|
46 |
'LoggerLevel' => '/LoggerLevel.php',
|
47 |
'LoggerLocationInfo' => '/LoggerLocationInfo.php',
|
@@ -52,7 +53,7 @@ class LoggerAutoloader {
|
|
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',
|
@@ -62,6 +63,7 @@ class LoggerAutoloader {
|
|
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',
|
@@ -76,7 +78,6 @@ class LoggerAutoloader {
|
|
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',
|
@@ -86,18 +87,34 @@ class LoggerAutoloader {
|
|
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',
|
@@ -110,9 +127,9 @@ class LoggerAutoloader {
|
|
110 |
'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php',
|
111 |
'LoggerRendererException' => '/renderers/LoggerRendererException.php',
|
112 |
'LoggerRendererMap' => '/renderers/LoggerRendererMap.php',
|
113 |
-
'
|
114 |
);
|
115 |
-
|
116 |
/**
|
117 |
* Loads a class.
|
118 |
* @param string $className The name of the class to load.
|
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 |
/**
|
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 |
|
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',
|
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',
|
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',
|
78 |
'LoggerConfiguratorDefault' => '/configurators/LoggerConfiguratorDefault.php',
|
79 |
|
80 |
// Filters
|
|
|
81 |
'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php',
|
82 |
'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php',
|
83 |
'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php',
|
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',
|
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.
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerConfigurable.php
RENAMED
@@ -99,7 +99,8 @@ abstract class LoggerConfigurable {
|
|
99 |
}
|
100 |
} else {
|
101 |
try {
|
102 |
-
$
|
|
|
103 |
} catch (Exception $ex) {
|
104 |
$value = var_export($value, true);
|
105 |
$this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
|
@@ -113,7 +114,3 @@ abstract class LoggerConfigurable {
|
|
113 |
trigger_error("log4php: $class: $message", E_USER_WARNING);
|
114 |
}
|
115 |
}
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
?>
|
99 |
}
|
100 |
} else {
|
101 |
try {
|
102 |
+
$value = LoggerOptionConverter::toStringEx($value);
|
103 |
+
$this->$property = LoggerOptionConverter::substConstants($value);
|
104 |
} catch (Exception $ex) {
|
105 |
$value = var_export($value, true);
|
106 |
$this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
|
114 |
trigger_error("log4php: $class: $message", E_USER_WARNING);
|
115 |
}
|
116 |
}
|
|
|
|
|
|
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerConfigurator.php
RENAMED
@@ -1,42 +1,42 @@
|
|
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 |
-
/**
|
22 |
-
* Interface for logger configurators.
|
23 |
-
*
|
24 |
-
* @package log4php
|
25 |
-
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
26 |
-
* @version $Revision: 1213710 $
|
27 |
-
* @since 2.2
|
28 |
-
*/
|
29 |
-
interface LoggerConfigurator
|
30 |
-
{
|
31 |
-
/**
|
32 |
-
* Configures log4php based on the given configuration.
|
33 |
-
*
|
34 |
-
* All configurators implementations must implement this interface.
|
35 |
-
*
|
36 |
-
* @param LoggerHierarchy $hierarchy The hierarchy on which to perform
|
37 |
-
* the configuration.
|
38 |
-
* @param mixed $input Either path to the config file or the
|
39 |
-
* configuration as an array.
|
40 |
-
*/
|
41 |
-
public function configure(LoggerHierarchy $hierarchy, $input = null);
|
42 |
}
|
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 |
+
/**
|
22 |
+
* Interface for logger configurators.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
26 |
+
* @version $Revision: 1213710 $
|
27 |
+
* @since 2.2
|
28 |
+
*/
|
29 |
+
interface LoggerConfigurator
|
30 |
+
{
|
31 |
+
/**
|
32 |
+
* Configures log4php based on the given configuration.
|
33 |
+
*
|
34 |
+
* All configurators implementations must implement this interface.
|
35 |
+
*
|
36 |
+
* @param LoggerHierarchy $hierarchy The hierarchy on which to perform
|
37 |
+
* the configuration.
|
38 |
+
* @param mixed $input Either path to the config file or the
|
39 |
+
* configuration as an array.
|
40 |
+
*/
|
41 |
+
public function configure(LoggerHierarchy $hierarchy, $input = null);
|
42 |
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerException.php
RENAMED
@@ -1,28 +1,28 @@
|
|
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 |
-
/**
|
22 |
-
* LoggerException class
|
23 |
-
*
|
24 |
-
* @version $Revision:
|
25 |
-
* @package log4php
|
26 |
-
*/
|
27 |
-
class LoggerException extends Exception {
|
28 |
-
}
|
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 |
+
/**
|
22 |
+
* LoggerException class
|
23 |
+
*
|
24 |
+
* @version $Revision: 1334369 $
|
25 |
+
* @package log4php
|
26 |
+
*/
|
27 |
+
class LoggerException extends Exception {
|
28 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerFilter.php
RENAMED
@@ -1,126 +1,126 @@
|
|
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 |
-
/**
|
22 |
-
* Users should extend this class to implement customized logging
|
23 |
-
* event filtering. Note that {@link LoggerCategory} and {@link LoggerAppender},
|
24 |
-
* the parent class of all standard
|
25 |
-
* appenders, have built-in filtering rules. It is suggested that you
|
26 |
-
* first use and understand the built-in rules before rushing to write
|
27 |
-
* your own custom filters.
|
28 |
-
*
|
29 |
-
* <p>This abstract class assumes and also imposes that filters be
|
30 |
-
* organized in a linear chain. The {@link #decide
|
31 |
-
* decide(LoggerLoggingEvent)} method of each filter is called sequentially,
|
32 |
-
* in the order of their addition to the chain.
|
33 |
-
*
|
34 |
-
* <p>The {@link decide()} method must return one
|
35 |
-
* of the integer constants {@link LoggerFilter::DENY},
|
36 |
-
* {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::ACCEPT}.
|
37 |
-
*
|
38 |
-
* <p>If the value {@link LoggerFilter::DENY} is returned, then the log event is
|
39 |
-
* dropped immediately without consulting with the remaining
|
40 |
-
* filters.
|
41 |
-
*
|
42 |
-
* <p>If the value {@link LoggerFilter::NEUTRAL} is returned, then the next filter
|
43 |
-
* in the chain is consulted. If there are no more filters in the
|
44 |
-
* chain, then the log event is logged. Thus, in the presence of no
|
45 |
-
* filters, the default behaviour is to log all logging events.
|
46 |
-
*
|
47 |
-
* <p>If the value {@link LoggerFilter::ACCEPT} is returned, then the log
|
48 |
-
* event is logged without consulting the remaining filters.
|
49 |
-
*
|
50 |
-
* <p>The philosophy of log4php filters is largely inspired from the
|
51 |
-
* Linux ipchains.
|
52 |
-
*
|
53 |
-
* @version $Revision: 1213283 $
|
54 |
-
* @package log4php
|
55 |
-
*/
|
56 |
-
abstract class LoggerFilter extends LoggerConfigurable {
|
57 |
-
|
58 |
-
/**
|
59 |
-
* The log event must be logged immediately without consulting with
|
60 |
-
* the remaining filters, if any, in the chain.
|
61 |
-
*/
|
62 |
-
const ACCEPT = 1;
|
63 |
-
|
64 |
-
/**
|
65 |
-
* This filter is neutral with respect to the log event. The
|
66 |
-
* remaining filters, if any, should be consulted for a final decision.
|
67 |
-
*/
|
68 |
-
const NEUTRAL = 0;
|
69 |
-
|
70 |
-
/**
|
71 |
-
* The log event must be dropped immediately without consulting
|
72 |
-
* with the remaining filters, if any, in the chain.
|
73 |
-
*/
|
74 |
-
const DENY = -1;
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain.
|
78 |
-
*/
|
79 |
-
protected $next;
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Usually filters options become active when set. We provide a
|
83 |
-
* default do-nothing implementation for convenience.
|
84 |
-
*/
|
85 |
-
public function activateOptions() {
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Decide what to do.
|
90 |
-
* <p>If the decision is {@link LoggerFilter::DENY}, then the event will be
|
91 |
-
* dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next
|
92 |
-
* filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then
|
93 |
-
* the event will be logged without consulting with other filters in
|
94 |
-
* the chain.
|
95 |
-
*
|
96 |
-
* @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon.
|
97 |
-
* @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT}
|
98 |
-
*/
|
99 |
-
public function decide(LoggerLoggingEvent $event) {
|
100 |
-
return self::NEUTRAL;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Adds a new filter to the filter chain this filter is a part of.
|
105 |
-
* If this filter has already and follow up filter, the param filter
|
106 |
-
* is passed on until it is the last filter in chain.
|
107 |
-
*
|
108 |
-
* @param $filter - the filter to add to this chain
|
109 |
-
*/
|
110 |
-
public function addNext($filter) {
|
111 |
-
if($this->next !== null) {
|
112 |
-
$this->next->addNext($filter);
|
113 |
-
} else {
|
114 |
-
$this->next = $filter;
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Returns the next filter in this chain
|
120 |
-
* @return the next filter
|
121 |
-
*/
|
122 |
-
public function getNext() {
|
123 |
-
return $this->next;
|
124 |
-
}
|
125 |
-
|
126 |
-
}
|
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 |
+
/**
|
22 |
+
* Users should extend this class to implement customized logging
|
23 |
+
* event filtering. Note that {@link LoggerCategory} and {@link LoggerAppender},
|
24 |
+
* the parent class of all standard
|
25 |
+
* appenders, have built-in filtering rules. It is suggested that you
|
26 |
+
* first use and understand the built-in rules before rushing to write
|
27 |
+
* your own custom filters.
|
28 |
+
*
|
29 |
+
* <p>This abstract class assumes and also imposes that filters be
|
30 |
+
* organized in a linear chain. The {@link #decide
|
31 |
+
* decide(LoggerLoggingEvent)} method of each filter is called sequentially,
|
32 |
+
* in the order of their addition to the chain.
|
33 |
+
*
|
34 |
+
* <p>The {@link decide()} method must return one
|
35 |
+
* of the integer constants {@link LoggerFilter::DENY},
|
36 |
+
* {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::ACCEPT}.
|
37 |
+
*
|
38 |
+
* <p>If the value {@link LoggerFilter::DENY} is returned, then the log event is
|
39 |
+
* dropped immediately without consulting with the remaining
|
40 |
+
* filters.
|
41 |
+
*
|
42 |
+
* <p>If the value {@link LoggerFilter::NEUTRAL} is returned, then the next filter
|
43 |
+
* in the chain is consulted. If there are no more filters in the
|
44 |
+
* chain, then the log event is logged. Thus, in the presence of no
|
45 |
+
* filters, the default behaviour is to log all logging events.
|
46 |
+
*
|
47 |
+
* <p>If the value {@link LoggerFilter::ACCEPT} is returned, then the log
|
48 |
+
* event is logged without consulting the remaining filters.
|
49 |
+
*
|
50 |
+
* <p>The philosophy of log4php filters is largely inspired from the
|
51 |
+
* Linux ipchains.
|
52 |
+
*
|
53 |
+
* @version $Revision: 1213283 $
|
54 |
+
* @package log4php
|
55 |
+
*/
|
56 |
+
abstract class LoggerFilter extends LoggerConfigurable {
|
57 |
+
|
58 |
+
/**
|
59 |
+
* The log event must be logged immediately without consulting with
|
60 |
+
* the remaining filters, if any, in the chain.
|
61 |
+
*/
|
62 |
+
const ACCEPT = 1;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* This filter is neutral with respect to the log event. The
|
66 |
+
* remaining filters, if any, should be consulted for a final decision.
|
67 |
+
*/
|
68 |
+
const NEUTRAL = 0;
|
69 |
+
|
70 |
+
/**
|
71 |
+
* The log event must be dropped immediately without consulting
|
72 |
+
* with the remaining filters, if any, in the chain.
|
73 |
+
*/
|
74 |
+
const DENY = -1;
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain.
|
78 |
+
*/
|
79 |
+
protected $next;
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Usually filters options become active when set. We provide a
|
83 |
+
* default do-nothing implementation for convenience.
|
84 |
+
*/
|
85 |
+
public function activateOptions() {
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Decide what to do.
|
90 |
+
* <p>If the decision is {@link LoggerFilter::DENY}, then the event will be
|
91 |
+
* dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next
|
92 |
+
* filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then
|
93 |
+
* the event will be logged without consulting with other filters in
|
94 |
+
* the chain.
|
95 |
+
*
|
96 |
+
* @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon.
|
97 |
+
* @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT}
|
98 |
+
*/
|
99 |
+
public function decide(LoggerLoggingEvent $event) {
|
100 |
+
return self::NEUTRAL;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Adds a new filter to the filter chain this filter is a part of.
|
105 |
+
* If this filter has already and follow up filter, the param filter
|
106 |
+
* is passed on until it is the last filter in chain.
|
107 |
+
*
|
108 |
+
* @param $filter - the filter to add to this chain
|
109 |
+
*/
|
110 |
+
public function addNext($filter) {
|
111 |
+
if($this->next !== null) {
|
112 |
+
$this->next->addNext($filter);
|
113 |
+
} else {
|
114 |
+
$this->next = $filter;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Returns the next filter in this chain
|
120 |
+
* @return the next filter
|
121 |
+
*/
|
122 |
+
public function getNext() {
|
123 |
+
return $this->next;
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerHierarchy.php
RENAMED
@@ -1,240 +1,257 @@
|
|
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 |
-
/**
|
22 |
-
* This class is specialized in retrieving loggers by name and also maintaining
|
23 |
-
* the logger hierarchy. The logger hierarchy is dealing with the several Log-Levels
|
24 |
-
* Logger can have. From log4j website:
|
25 |
-
*
|
26 |
-
* "A logger is said to be an ancestor of another logger if its name followed
|
27 |
-
* by a dot is a prefix of the descendant logger name. A logger is said to be
|
28 |
-
* a parent of a child logger if there are no ancestors between itself and the
|
29 |
-
* descendant logger."
|
30 |
-
*
|
31 |
-
* Child Loggers do inherit their Log-Levels from their Ancestors. They can
|
32 |
-
* increase their Log-Level compared to their Ancestors, but they cannot decrease it.
|
33 |
-
*
|
34 |
-
* <p>The casual user does not have to deal with this class directly.</p>
|
35 |
-
*
|
36 |
-
* <p>The structure of the logger hierarchy is maintained by the
|
37 |
-
* getLogger method. The hierarchy is such that children link
|
38 |
-
* to their parent but parents do not have any pointers to their
|
39 |
-
* children. Moreover, loggers can be instantiated in any order, in
|
40 |
-
* particular descendant before ancestor.</p>
|
41 |
-
*
|
42 |
-
* <p>In case a descendant is created before a particular ancestor,
|
43 |
-
* then it creates a provision node for the ancestor and adds itself
|
44 |
-
* to the provision node. Other descendants of the same ancestor add
|
45 |
-
* themselves to the previously created provision node.</p>
|
46 |
-
*
|
47 |
-
* @version $Revision:
|
48 |
-
* @package log4php
|
49 |
-
*/
|
50 |
-
class LoggerHierarchy {
|
51 |
-
|
52 |
-
/** Array holding all Logger instances. */
|
53 |
-
protected $loggers = array();
|
54 |
-
|
55 |
-
/**
|
56 |
-
* The root logger.
|
57 |
-
* @var RootLogger
|
58 |
-
*/
|
59 |
-
protected $root
|
60 |
-
|
61 |
-
/**
|
62 |
-
* The logger renderer map.
|
63 |
-
* @var LoggerRendererMap
|
64 |
-
*/
|
65 |
-
protected $rendererMap;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Main level threshold. Events with lower level will not be logged by any
|
69 |
-
* logger, regardless of it's configuration.
|
70 |
-
* @var LoggerLevel
|
71 |
-
*/
|
72 |
-
protected $threshold;
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Creates a new logger hierarchy.
|
76 |
-
* @param LoggerRoot $root The root logger.
|
77 |
-
*/
|
78 |
-
public function __construct(LoggerRoot $root) {
|
79 |
-
$this->root = $root;
|
80 |
-
$this->setThreshold(LoggerLevel::getLevelAll());
|
81 |
-
$this->rendererMap = new LoggerRendererMap();
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Clears all loggers.
|
86 |
-
*/
|
87 |
-
public function clear() {
|
88 |
-
$this->loggers = array();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Check if the named logger exists in the hierarchy.
|
93 |
-
* @param string $name
|
94 |
-
* @return boolean
|
95 |
-
*/
|
96 |
-
public function exists($name) {
|
97 |
-
return isset($this->loggers[$name]);
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Returns all the currently defined loggers in this hierarchy as an array.
|
102 |
-
* @return array
|
103 |
-
*/
|
104 |
-
public function getCurrentLoggers() {
|
105 |
-
return array_values($this->loggers);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Returns a named logger instance logger. If it doesn't exist, one is created.
|
110 |
-
*
|
111 |
-
* @param string $name Logger name
|
112 |
-
* @return Logger Logger instance.
|
113 |
-
*/
|
114 |
-
public function getLogger($name) {
|
115 |
-
if(!isset($this->loggers[$name])) {
|
116 |
-
$logger = new Logger($name);
|
117 |
-
|
118 |
-
$nodes = explode('.', $name);
|
119 |
-
$firstNode = array_shift($nodes);
|
120 |
-
|
121 |
-
// if name is not a first node but another first node is their
|
122 |
-
if($firstNode != $name and isset($this->loggers[$firstNode])) {
|
123 |
-
$logger->setParent($this->loggers[$firstNode]);
|
124 |
-
} else {
|
125 |
-
// if there is no father, set root logger as father
|
126 |
-
$logger->setParent($this->root);
|
127 |
-
}
|
128 |
-
|
129 |
-
// if there are more nodes than one
|
130 |
-
if(count($nodes) > 0) {
|
131 |
-
// find parent node
|
132 |
-
foreach($nodes as $node) {
|
133 |
-
$parentNode = "$firstNode.$node";
|
134 |
-
if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
|
135 |
-
$logger->setParent($this->loggers[$parentNode]);
|
136 |
-
}
|
137 |
-
$firstNode .= ".$node";
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
$this->loggers[$name] = $logger;
|
142 |
-
}
|
143 |
-
|
144 |
-
return $this->loggers[$name];
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Returns the logger renderer map.
|
149 |
-
* @return LoggerRendererMap
|
150 |
-
*/
|
151 |
-
public function getRendererMap() {
|
152 |
-
return $this->rendererMap;
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Returns the root logger.
|
157 |
-
* @return LoggerRoot
|
158 |
-
*/
|
159 |
-
public function getRootLogger() {
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
*
|
185 |
-
*
|
186 |
-
*
|
187 |
-
*
|
188 |
-
*
|
189 |
-
*
|
190 |
-
*
|
191 |
-
*
|
192 |
-
*
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
$this->
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
*
|
224 |
-
*
|
225 |
-
*
|
226 |
-
*
|
227 |
-
*
|
228 |
-
*
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* This class is specialized in retrieving loggers by name and also maintaining
|
23 |
+
* the logger hierarchy. The logger hierarchy is dealing with the several Log-Levels
|
24 |
+
* Logger can have. From log4j website:
|
25 |
+
*
|
26 |
+
* "A logger is said to be an ancestor of another logger if its name followed
|
27 |
+
* by a dot is a prefix of the descendant logger name. A logger is said to be
|
28 |
+
* a parent of a child logger if there are no ancestors between itself and the
|
29 |
+
* descendant logger."
|
30 |
+
*
|
31 |
+
* Child Loggers do inherit their Log-Levels from their Ancestors. They can
|
32 |
+
* increase their Log-Level compared to their Ancestors, but they cannot decrease it.
|
33 |
+
*
|
34 |
+
* <p>The casual user does not have to deal with this class directly.</p>
|
35 |
+
*
|
36 |
+
* <p>The structure of the logger hierarchy is maintained by the
|
37 |
+
* getLogger method. The hierarchy is such that children link
|
38 |
+
* to their parent but parents do not have any pointers to their
|
39 |
+
* children. Moreover, loggers can be instantiated in any order, in
|
40 |
+
* particular descendant before ancestor.</p>
|
41 |
+
*
|
42 |
+
* <p>In case a descendant is created before a particular ancestor,
|
43 |
+
* then it creates a provision node for the ancestor and adds itself
|
44 |
+
* to the provision node. Other descendants of the same ancestor add
|
45 |
+
* themselves to the previously created provision node.</p>
|
46 |
+
*
|
47 |
+
* @version $Revision: 1394956 $
|
48 |
+
* @package log4php
|
49 |
+
*/
|
50 |
+
class LoggerHierarchy {
|
51 |
+
|
52 |
+
/** Array holding all Logger instances. */
|
53 |
+
protected $loggers = array();
|
54 |
+
|
55 |
+
/**
|
56 |
+
* The root logger.
|
57 |
+
* @var RootLogger
|
58 |
+
*/
|
59 |
+
protected $root;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* The logger renderer map.
|
63 |
+
* @var LoggerRendererMap
|
64 |
+
*/
|
65 |
+
protected $rendererMap;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Main level threshold. Events with lower level will not be logged by any
|
69 |
+
* logger, regardless of it's configuration.
|
70 |
+
* @var LoggerLevel
|
71 |
+
*/
|
72 |
+
protected $threshold;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Creates a new logger hierarchy.
|
76 |
+
* @param LoggerRoot $root The root logger.
|
77 |
+
*/
|
78 |
+
public function __construct(LoggerRoot $root) {
|
79 |
+
$this->root = $root;
|
80 |
+
$this->setThreshold(LoggerLevel::getLevelAll());
|
81 |
+
$this->rendererMap = new LoggerRendererMap();
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Clears all loggers.
|
86 |
+
*/
|
87 |
+
public function clear() {
|
88 |
+
$this->loggers = array();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Check if the named logger exists in the hierarchy.
|
93 |
+
* @param string $name
|
94 |
+
* @return boolean
|
95 |
+
*/
|
96 |
+
public function exists($name) {
|
97 |
+
return isset($this->loggers[$name]);
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Returns all the currently defined loggers in this hierarchy as an array.
|
102 |
+
* @return array
|
103 |
+
*/
|
104 |
+
public function getCurrentLoggers() {
|
105 |
+
return array_values($this->loggers);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Returns a named logger instance logger. If it doesn't exist, one is created.
|
110 |
+
*
|
111 |
+
* @param string $name Logger name
|
112 |
+
* @return Logger Logger instance.
|
113 |
+
*/
|
114 |
+
public function getLogger($name) {
|
115 |
+
if(!isset($this->loggers[$name])) {
|
116 |
+
$logger = new Logger($name);
|
117 |
+
|
118 |
+
$nodes = explode('.', $name);
|
119 |
+
$firstNode = array_shift($nodes);
|
120 |
+
|
121 |
+
// if name is not a first node but another first node is their
|
122 |
+
if($firstNode != $name and isset($this->loggers[$firstNode])) {
|
123 |
+
$logger->setParent($this->loggers[$firstNode]);
|
124 |
+
} else {
|
125 |
+
// if there is no father, set root logger as father
|
126 |
+
$logger->setParent($this->root);
|
127 |
+
}
|
128 |
+
|
129 |
+
// if there are more nodes than one
|
130 |
+
if(count($nodes) > 0) {
|
131 |
+
// find parent node
|
132 |
+
foreach($nodes as $node) {
|
133 |
+
$parentNode = "$firstNode.$node";
|
134 |
+
if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
|
135 |
+
$logger->setParent($this->loggers[$parentNode]);
|
136 |
+
}
|
137 |
+
$firstNode .= ".$node";
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
$this->loggers[$name] = $logger;
|
142 |
+
}
|
143 |
+
|
144 |
+
return $this->loggers[$name];
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Returns the logger renderer map.
|
149 |
+
* @return LoggerRendererMap
|
150 |
+
*/
|
151 |
+
public function getRendererMap() {
|
152 |
+
return $this->rendererMap;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Returns the root logger.
|
157 |
+
* @return LoggerRoot
|
158 |
+
*/
|
159 |
+
public function getRootLogger() {
|
160 |
+
return $this->root;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Returns the main threshold level.
|
165 |
+
* @return LoggerLevel
|
166 |
+
*/
|
167 |
+
public function getThreshold() {
|
168 |
+
return $this->threshold;
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Returns true if the hierarchy is disabled for given log level and false
|
173 |
+
* otherwise.
|
174 |
+
* @return boolean
|
175 |
+
*/
|
176 |
+
public function isDisabled(LoggerLevel $level) {
|
177 |
+
return ($this->threshold->toInt() > $level->toInt());
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Reset all values contained in this hierarchy instance to their
|
182 |
+
* default.
|
183 |
+
*
|
184 |
+
* This removes all appenders from all loggers, sets
|
185 |
+
* the level of all non-root loggers to <i>null</i>,
|
186 |
+
* sets their additivity flag to <i>true</i> and sets the level
|
187 |
+
* of the root logger to {@link LOGGER_LEVEL_DEBUG}.
|
188 |
+
*
|
189 |
+
* <p>Existing loggers are not removed. They are just reset.
|
190 |
+
*
|
191 |
+
* <p>This method should be used sparingly and with care as it will
|
192 |
+
* block all logging until it is completed.</p>
|
193 |
+
*/
|
194 |
+
public function resetConfiguration() {
|
195 |
+
$root = $this->getRootLogger();
|
196 |
+
|
197 |
+
$root->setLevel(LoggerLevel::getLevelDebug());
|
198 |
+
$this->setThreshold(LoggerLevel::getLevelAll());
|
199 |
+
$this->shutDown();
|
200 |
+
|
201 |
+
foreach($this->loggers as $logger) {
|
202 |
+
$logger->setLevel(null);
|
203 |
+
$logger->setAdditivity(true);
|
204 |
+
$logger->removeAllAppenders();
|
205 |
+
}
|
206 |
+
|
207 |
+
$this->rendererMap->reset();
|
208 |
+
LoggerAppenderPool::clear();
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Sets the main threshold level.
|
213 |
+
* @param LoggerLevel $l
|
214 |
+
*/
|
215 |
+
public function setThreshold(LoggerLevel $threshold) {
|
216 |
+
$this->threshold = $threshold;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Shutting down a hierarchy will <i>safely</i> close and remove
|
221 |
+
* all appenders in all loggers including the root logger.
|
222 |
+
*
|
223 |
+
* The shutdown method is careful to close nested
|
224 |
+
* appenders before closing regular appenders. This is allows
|
225 |
+
* configurations where a regular appender is attached to a logger
|
226 |
+
* and again to a nested appender.
|
227 |
+
*
|
228 |
+
* @todo Check if the last paragraph is correct.
|
229 |
+
*/
|
230 |
+
public function shutdown() {
|
231 |
+
$this->root->removeAllAppenders();
|
232 |
+
|
233 |
+
foreach($this->loggers as $logger) {
|
234 |
+
$logger->removeAllAppenders();
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Prints the current Logger hierarchy tree. Useful for debugging.
|
240 |
+
*/
|
241 |
+
public function printHierarchy() {
|
242 |
+
$this->printHierarchyInner($this->getRootLogger(), 0);
|
243 |
+
}
|
244 |
+
|
245 |
+
private function printHierarchyInner(Logger $current, $level) {
|
246 |
+
for ($i = 0; $i < $level; $i++) {
|
247 |
+
echo ($i == $level - 1) ? "|--" : "| ";
|
248 |
+
}
|
249 |
+
echo $current->getName() . "\n";
|
250 |
+
|
251 |
+
foreach($this->loggers as $logger) {
|
252 |
+
if ($logger->getParent() == $current) {
|
253 |
+
$this->printHierarchyInner($logger, $level + 1);
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerLayout.php
RENAMED
@@ -1,74 +1,74 @@
|
|
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 |
-
/**
|
22 |
-
* Extend this abstract class to create your own log layout format.
|
23 |
-
*
|
24 |
-
* @version $Revision: 1213283 $
|
25 |
-
* @package log4php
|
26 |
-
*/
|
27 |
-
abstract class LoggerLayout extends LoggerConfigurable {
|
28 |
-
/**
|
29 |
-
* Activates options for this layout.
|
30 |
-
* Override this method if you have options to be activated.
|
31 |
-
*/
|
32 |
-
public function activateOptions() {
|
33 |
-
return true;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Override this method to create your own layout format.
|
38 |
-
*
|
39 |
-
* @param LoggerLoggingEvent
|
40 |
-
* @return string
|
41 |
-
*/
|
42 |
-
public function format(LoggerLoggingEvent $event) {
|
43 |
-
return $event->getRenderedMessage();
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Returns the content type output by this layout.
|
48 |
-
* @return string
|
49 |
-
*/
|
50 |
-
public function getContentType() {
|
51 |
-
return "text/plain";
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Returns the footer for the layout format.
|
56 |
-
* @return string
|
57 |
-
*/
|
58 |
-
public function getFooter() {
|
59 |
-
return null;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Returns the header for the layout format.
|
64 |
-
* @return string
|
65 |
-
*/
|
66 |
-
public function getHeader() {
|
67 |
-
return null;
|
68 |
-
}
|
69 |
-
|
70 |
-
/** Triggers a warning for this layout with the given message. */
|
71 |
-
protected function warn($message) {
|
72 |
-
trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
|
73 |
-
}
|
74 |
-
}
|
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 |
+
/**
|
22 |
+
* Extend this abstract class to create your own log layout format.
|
23 |
+
*
|
24 |
+
* @version $Revision: 1213283 $
|
25 |
+
* @package log4php
|
26 |
+
*/
|
27 |
+
abstract class LoggerLayout extends LoggerConfigurable {
|
28 |
+
/**
|
29 |
+
* Activates options for this layout.
|
30 |
+
* Override this method if you have options to be activated.
|
31 |
+
*/
|
32 |
+
public function activateOptions() {
|
33 |
+
return true;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Override this method to create your own layout format.
|
38 |
+
*
|
39 |
+
* @param LoggerLoggingEvent
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function format(LoggerLoggingEvent $event) {
|
43 |
+
return $event->getRenderedMessage();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Returns the content type output by this layout.
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function getContentType() {
|
51 |
+
return "text/plain";
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Returns the footer for the layout format.
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public function getFooter() {
|
59 |
+
return null;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns the header for the layout format.
|
64 |
+
* @return string
|
65 |
+
*/
|
66 |
+
public function getHeader() {
|
67 |
+
return null;
|
68 |
+
}
|
69 |
+
|
70 |
+
/** Triggers a warning for this layout with the given message. */
|
71 |
+
protected function warn($message) {
|
72 |
+
trigger_error("log4php: [" . get_class($this) . "]: $message", E_USER_WARNING);
|
73 |
+
}
|
74 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerLevel.php
RENAMED
@@ -1,256 +1,256 @@
|
|
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 |
-
/**
|
22 |
-
* Defines the minimum set of levels recognized by the system, that is
|
23 |
-
* <i>OFF</i>, <i>FATAL</i>, <i>ERROR</i>,
|
24 |
-
* <i>WARN</i>, <i>INFO</i>, <i>DEBUG</i> and
|
25 |
-
* <i>ALL</i>.
|
26 |
-
*
|
27 |
-
* <p>The <i>LoggerLevel</i> class may be subclassed to define a larger
|
28 |
-
* level set.</p>
|
29 |
-
*
|
30 |
-
* @version $Revision:
|
31 |
-
* @package log4php
|
32 |
-
* @since 0.5
|
33 |
-
*/
|
34 |
-
class LoggerLevel {
|
35 |
-
|
36 |
-
const OFF = 2147483647;
|
37 |
-
const FATAL = 50000;
|
38 |
-
const ERROR = 40000;
|
39 |
-
const WARN = 30000;
|
40 |
-
const INFO = 20000;
|
41 |
-
const DEBUG = 10000;
|
42 |
-
const TRACE = 5000;
|
43 |
-
const ALL = -2147483647;
|
44 |
-
|
45 |
-
/** Integer level value. */
|
46 |
-
private $level;
|
47 |
-
|
48 |
-
/** Contains a list of instantiated levels. */
|
49 |
-
private static $levelMap;
|
50 |
-
|
51 |
-
/** String representation of the level. */
|
52 |
-
private $levelStr;
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Equivalent syslog level.
|
56 |
-
* @var integer
|
57 |
-
*/
|
58 |
-
private $syslogEquivalent;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Constructor
|
62 |
-
*
|
63 |
-
* @param integer $level
|
64 |
-
* @param string $levelStr
|
65 |
-
* @param integer $syslogEquivalent
|
66 |
-
*/
|
67 |
-
private function __construct($level, $levelStr, $syslogEquivalent) {
|
68 |
-
$this->level = $level;
|
69 |
-
$this->levelStr = $levelStr;
|
70 |
-
$this->syslogEquivalent = $syslogEquivalent;
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Compares two logger levels.
|
75 |
-
*
|
76 |
-
* @param LoggerLevels $other
|
77 |
-
* @return boolean
|
78 |
-
*/
|
79 |
-
public function equals($other) {
|
80 |
-
if($other instanceof LoggerLevel) {
|
81 |
-
if($this->level == $other->level) {
|
82 |
-
return true;
|
83 |
-
}
|
84 |
-
} else {
|
85 |
-
return false;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Returns an Off Level
|
91 |
-
* @return LoggerLevel
|
92 |
-
*/
|
93 |
-
public static function getLevelOff() {
|
94 |
-
if(!isset(self::$levelMap[LoggerLevel::OFF])) {
|
95 |
-
self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', LOG_ALERT);
|
96 |
-
}
|
97 |
-
return self::$levelMap[LoggerLevel::OFF];
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Returns a Fatal Level
|
102 |
-
* @return LoggerLevel
|
103 |
-
*/
|
104 |
-
public static function getLevelFatal() {
|
105 |
-
if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
|
106 |
-
self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
|
107 |
-
}
|
108 |
-
return self::$levelMap[LoggerLevel::FATAL];
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Returns an Error Level
|
113 |
-
* @return LoggerLevel
|
114 |
-
*/
|
115 |
-
public static function getLevelError() {
|
116 |
-
if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
|
117 |
-
self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', LOG_ERR);
|
118 |
-
}
|
119 |
-
return self::$levelMap[LoggerLevel::ERROR];
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Returns a Warn Level
|
124 |
-
* @return LoggerLevel
|
125 |
-
*/
|
126 |
-
public static function getLevelWarn() {
|
127 |
-
if(!isset(self::$levelMap[LoggerLevel::WARN])) {
|
128 |
-
self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', LOG_WARNING);
|
129 |
-
}
|
130 |
-
return self::$levelMap[LoggerLevel::WARN];
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Returns an Info Level
|
135 |
-
* @return LoggerLevel
|
136 |
-
*/
|
137 |
-
public static function getLevelInfo() {
|
138 |
-
if(!isset(self::$levelMap[LoggerLevel::INFO])) {
|
139 |
-
self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', LOG_INFO);
|
140 |
-
}
|
141 |
-
return self::$levelMap[LoggerLevel::INFO];
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Returns a Debug Level
|
146 |
-
* @return LoggerLevel
|
147 |
-
*/
|
148 |
-
public static function getLevelDebug() {
|
149 |
-
if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
|
150 |
-
self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
|
151 |
-
}
|
152 |
-
return self::$levelMap[LoggerLevel::DEBUG];
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Returns a Trace Level
|
157 |
-
* @return LoggerLevel
|
158 |
-
*/
|
159 |
-
public static function getLevelTrace() {
|
160 |
-
if(!isset(self::$levelMap[LoggerLevel::TRACE])) {
|
161 |
-
self::$levelMap[LoggerLevel::TRACE] = new LoggerLevel(LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
|
162 |
-
}
|
163 |
-
return self::$levelMap[LoggerLevel::TRACE];
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* Returns an All Level
|
168 |
-
* @return LoggerLevel
|
169 |
-
*/
|
170 |
-
public static function getLevelAll() {
|
171 |
-
if(!isset(self::$levelMap[LoggerLevel::ALL])) {
|
172 |
-
self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', LOG_DEBUG);
|
173 |
-
}
|
174 |
-
return self::$levelMap[LoggerLevel::ALL];
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Return the syslog equivalent of this
|
179 |
-
* @return integer
|
180 |
-
*/
|
181 |
-
public function getSyslogEquivalent() {
|
182 |
-
return $this->syslogEquivalent;
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Returns <i>true</i> if this level has a higher or equal
|
187 |
-
* level than the level passed as argument, <i>false</i>
|
188 |
-
* otherwise.
|
189 |
-
*
|
190 |
-
* @param LoggerLevel $other
|
191 |
-
* @return boolean
|
192 |
-
*/
|
193 |
-
public function isGreaterOrEqual($other) {
|
194 |
-
return $this->level >= $other->level;
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Returns the string representation of this level.
|
199 |
-
* @return string
|
200 |
-
*/
|
201 |
-
public function toString() {
|
202 |
-
return $this->levelStr;
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Returns the string representation of this level.
|
207 |
-
* @return string
|
208 |
-
*/
|
209 |
-
public function __toString() {
|
210 |
-
return $this->toString();
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Returns the integer representation of this level.
|
215 |
-
* @return integer
|
216 |
-
*/
|
217 |
-
public function toInt() {
|
218 |
-
return $this->level;
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Convert the input argument to a level. If the conversion fails, then
|
223 |
-
* this method returns the provided default level.
|
224 |
-
*
|
225 |
-
* @param mixed $arg The value to convert to level.
|
226 |
-
* @param LoggerLevel $default Value to return if conversion is not possible.
|
227 |
-
* @return LoggerLevel
|
228 |
-
*/
|
229 |
-
public static function toLevel($arg, $defaultLevel = null) {
|
230 |
-
if(is_int($arg)) {
|
231 |
-
switch($arg) {
|
232 |
-
case self::ALL: return self::getLevelAll();
|
233 |
-
case self::TRACE: return self::getLevelTrace();
|
234 |
-
case self::DEBUG: return self::getLevelDebug();
|
235 |
-
case self::INFO: return self::getLevelInfo();
|
236 |
-
case self::WARN: return self::getLevelWarn();
|
237 |
-
case self::ERROR: return self::getLevelError();
|
238 |
-
case self::FATAL: return self::getLevelFatal();
|
239 |
-
case self::OFF: return self::getLevelOff();
|
240 |
-
default: return $defaultLevel;
|
241 |
-
}
|
242 |
-
} else {
|
243 |
-
switch(strtoupper($arg)) {
|
244 |
-
case 'ALL': return self::getLevelAll();
|
245 |
-
case 'TRACE': return self::getLevelTrace();
|
246 |
-
case 'DEBUG': return self::getLevelDebug();
|
247 |
-
case 'INFO': return self::getLevelInfo();
|
248 |
-
case 'WARN': return self::getLevelWarn();
|
249 |
-
case 'ERROR': return self::getLevelError();
|
250 |
-
case 'FATAL': return self::getLevelFatal();
|
251 |
-
case 'OFF': return self::getLevelOff();
|
252 |
-
default: return $defaultLevel;
|
253 |
-
}
|
254 |
-
}
|
255 |
-
}
|
256 |
-
}
|
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 |
+
/**
|
22 |
+
* Defines the minimum set of levels recognized by the system, that is
|
23 |
+
* <i>OFF</i>, <i>FATAL</i>, <i>ERROR</i>,
|
24 |
+
* <i>WARN</i>, <i>INFO</i>, <i>DEBUG</i> and
|
25 |
+
* <i>ALL</i>.
|
26 |
+
*
|
27 |
+
* <p>The <i>LoggerLevel</i> class may be subclassed to define a larger
|
28 |
+
* level set.</p>
|
29 |
+
*
|
30 |
+
* @version $Revision: 1379729 $
|
31 |
+
* @package log4php
|
32 |
+
* @since 0.5
|
33 |
+
*/
|
34 |
+
class LoggerLevel {
|
35 |
+
|
36 |
+
const OFF = 2147483647;
|
37 |
+
const FATAL = 50000;
|
38 |
+
const ERROR = 40000;
|
39 |
+
const WARN = 30000;
|
40 |
+
const INFO = 20000;
|
41 |
+
const DEBUG = 10000;
|
42 |
+
const TRACE = 5000;
|
43 |
+
const ALL = -2147483647;
|
44 |
+
|
45 |
+
/** Integer level value. */
|
46 |
+
private $level;
|
47 |
+
|
48 |
+
/** Contains a list of instantiated levels. */
|
49 |
+
private static $levelMap;
|
50 |
+
|
51 |
+
/** String representation of the level. */
|
52 |
+
private $levelStr;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Equivalent syslog level.
|
56 |
+
* @var integer
|
57 |
+
*/
|
58 |
+
private $syslogEquivalent;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Constructor
|
62 |
+
*
|
63 |
+
* @param integer $level
|
64 |
+
* @param string $levelStr
|
65 |
+
* @param integer $syslogEquivalent
|
66 |
+
*/
|
67 |
+
private function __construct($level, $levelStr, $syslogEquivalent) {
|
68 |
+
$this->level = $level;
|
69 |
+
$this->levelStr = $levelStr;
|
70 |
+
$this->syslogEquivalent = $syslogEquivalent;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Compares two logger levels.
|
75 |
+
*
|
76 |
+
* @param LoggerLevels $other
|
77 |
+
* @return boolean
|
78 |
+
*/
|
79 |
+
public function equals($other) {
|
80 |
+
if($other instanceof LoggerLevel) {
|
81 |
+
if($this->level == $other->level) {
|
82 |
+
return true;
|
83 |
+
}
|
84 |
+
} else {
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Returns an Off Level
|
91 |
+
* @return LoggerLevel
|
92 |
+
*/
|
93 |
+
public static function getLevelOff() {
|
94 |
+
if(!isset(self::$levelMap[LoggerLevel::OFF])) {
|
95 |
+
self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', LOG_ALERT);
|
96 |
+
}
|
97 |
+
return self::$levelMap[LoggerLevel::OFF];
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Returns a Fatal Level
|
102 |
+
* @return LoggerLevel
|
103 |
+
*/
|
104 |
+
public static function getLevelFatal() {
|
105 |
+
if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
|
106 |
+
self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
|
107 |
+
}
|
108 |
+
return self::$levelMap[LoggerLevel::FATAL];
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Returns an Error Level
|
113 |
+
* @return LoggerLevel
|
114 |
+
*/
|
115 |
+
public static function getLevelError() {
|
116 |
+
if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
|
117 |
+
self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', LOG_ERR);
|
118 |
+
}
|
119 |
+
return self::$levelMap[LoggerLevel::ERROR];
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Returns a Warn Level
|
124 |
+
* @return LoggerLevel
|
125 |
+
*/
|
126 |
+
public static function getLevelWarn() {
|
127 |
+
if(!isset(self::$levelMap[LoggerLevel::WARN])) {
|
128 |
+
self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', LOG_WARNING);
|
129 |
+
}
|
130 |
+
return self::$levelMap[LoggerLevel::WARN];
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Returns an Info Level
|
135 |
+
* @return LoggerLevel
|
136 |
+
*/
|
137 |
+
public static function getLevelInfo() {
|
138 |
+
if(!isset(self::$levelMap[LoggerLevel::INFO])) {
|
139 |
+
self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', LOG_INFO);
|
140 |
+
}
|
141 |
+
return self::$levelMap[LoggerLevel::INFO];
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Returns a Debug Level
|
146 |
+
* @return LoggerLevel
|
147 |
+
*/
|
148 |
+
public static function getLevelDebug() {
|
149 |
+
if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
|
150 |
+
self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
|
151 |
+
}
|
152 |
+
return self::$levelMap[LoggerLevel::DEBUG];
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Returns a Trace Level
|
157 |
+
* @return LoggerLevel
|
158 |
+
*/
|
159 |
+
public static function getLevelTrace() {
|
160 |
+
if(!isset(self::$levelMap[LoggerLevel::TRACE])) {
|
161 |
+
self::$levelMap[LoggerLevel::TRACE] = new LoggerLevel(LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
|
162 |
+
}
|
163 |
+
return self::$levelMap[LoggerLevel::TRACE];
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Returns an All Level
|
168 |
+
* @return LoggerLevel
|
169 |
+
*/
|
170 |
+
public static function getLevelAll() {
|
171 |
+
if(!isset(self::$levelMap[LoggerLevel::ALL])) {
|
172 |
+
self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', LOG_DEBUG);
|
173 |
+
}
|
174 |
+
return self::$levelMap[LoggerLevel::ALL];
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Return the syslog equivalent of this level as an integer.
|
179 |
+
* @return integer
|
180 |
+
*/
|
181 |
+
public function getSyslogEquivalent() {
|
182 |
+
return $this->syslogEquivalent;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Returns <i>true</i> if this level has a higher or equal
|
187 |
+
* level than the level passed as argument, <i>false</i>
|
188 |
+
* otherwise.
|
189 |
+
*
|
190 |
+
* @param LoggerLevel $other
|
191 |
+
* @return boolean
|
192 |
+
*/
|
193 |
+
public function isGreaterOrEqual($other) {
|
194 |
+
return $this->level >= $other->level;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Returns the string representation of this level.
|
199 |
+
* @return string
|
200 |
+
*/
|
201 |
+
public function toString() {
|
202 |
+
return $this->levelStr;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Returns the string representation of this level.
|
207 |
+
* @return string
|
208 |
+
*/
|
209 |
+
public function __toString() {
|
210 |
+
return $this->toString();
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Returns the integer representation of this level.
|
215 |
+
* @return integer
|
216 |
+
*/
|
217 |
+
public function toInt() {
|
218 |
+
return $this->level;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Convert the input argument to a level. If the conversion fails, then
|
223 |
+
* this method returns the provided default level.
|
224 |
+
*
|
225 |
+
* @param mixed $arg The value to convert to level.
|
226 |
+
* @param LoggerLevel $default Value to return if conversion is not possible.
|
227 |
+
* @return LoggerLevel
|
228 |
+
*/
|
229 |
+
public static function toLevel($arg, $defaultLevel = null) {
|
230 |
+
if(is_int($arg)) {
|
231 |
+
switch($arg) {
|
232 |
+
case self::ALL: return self::getLevelAll();
|
233 |
+
case self::TRACE: return self::getLevelTrace();
|
234 |
+
case self::DEBUG: return self::getLevelDebug();
|
235 |
+
case self::INFO: return self::getLevelInfo();
|
236 |
+
case self::WARN: return self::getLevelWarn();
|
237 |
+
case self::ERROR: return self::getLevelError();
|
238 |
+
case self::FATAL: return self::getLevelFatal();
|
239 |
+
case self::OFF: return self::getLevelOff();
|
240 |
+
default: return $defaultLevel;
|
241 |
+
}
|
242 |
+
} else {
|
243 |
+
switch(strtoupper($arg)) {
|
244 |
+
case 'ALL': return self::getLevelAll();
|
245 |
+
case 'TRACE': return self::getLevelTrace();
|
246 |
+
case 'DEBUG': return self::getLevelDebug();
|
247 |
+
case 'INFO': return self::getLevelInfo();
|
248 |
+
case 'WARN': return self::getLevelWarn();
|
249 |
+
case 'ERROR': return self::getLevelError();
|
250 |
+
case 'FATAL': return self::getLevelFatal();
|
251 |
+
case 'OFF': return self::getLevelOff();
|
252 |
+
default: return $defaultLevel;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerLocationInfo.php
RENAMED
@@ -1,110 +1,103 @@
|
|
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 |
-
/**
|
22 |
-
* The internal representation of caller location information.
|
23 |
-
*
|
24 |
-
* @version $Revision:
|
25 |
-
* @package log4php
|
26 |
-
* @since 0.3
|
27 |
-
*/
|
28 |
-
class LoggerLocationInfo {
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
protected $className
|
50 |
-
|
51 |
-
/**
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
* @
|
65 |
-
*
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
$this->
|
71 |
-
$this->
|
72 |
-
$this->
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
public function getFileName() {
|
85 |
-
return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
public function
|
100 |
-
return ($this->
|
101 |
-
}
|
102 |
-
|
103 |
-
|
104 |
-
* Returns the full information of the caller.
|
105 |
-
*/
|
106 |
-
public function getFullInfo() {
|
107 |
-
return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
|
108 |
-
}
|
109 |
-
|
110 |
-
}
|
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 |
+
/**
|
22 |
+
* The internal representation of caller location information.
|
23 |
+
*
|
24 |
+
* @version $Revision: 1379738 $
|
25 |
+
* @package log4php
|
26 |
+
* @since 0.3
|
27 |
+
*/
|
28 |
+
class LoggerLocationInfo {
|
29 |
+
|
30 |
+
/** The value to return when the location information is not available. */
|
31 |
+
const LOCATION_INFO_NA = 'NA';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Caller line number.
|
35 |
+
* @var integer
|
36 |
+
*/
|
37 |
+
protected $lineNumber;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Caller file name.
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
protected $fileName;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Caller class name.
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $className;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Caller method name.
|
53 |
+
* @var string
|
54 |
+
*/
|
55 |
+
protected $methodName;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* All the information combined.
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
protected $fullInfo;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
|
65 |
+
*
|
66 |
+
* @param array $trace
|
67 |
+
* @param mixed $caller
|
68 |
+
*/
|
69 |
+
public function __construct($trace, $fqcn = null) {
|
70 |
+
$this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
|
71 |
+
$this->fileName = isset($trace['file']) ? $trace['file'] : null;
|
72 |
+
$this->className = isset($trace['class']) ? $trace['class'] : null;
|
73 |
+
$this->methodName = isset($trace['function']) ? $trace['function'] : null;
|
74 |
+
$this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() .
|
75 |
+
'(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
|
76 |
+
}
|
77 |
+
|
78 |
+
/** Returns the caller class name. */
|
79 |
+
public function getClassName() {
|
80 |
+
return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className;
|
81 |
+
}
|
82 |
+
|
83 |
+
/** Returns the caller file name. */
|
84 |
+
public function getFileName() {
|
85 |
+
return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName;
|
86 |
+
}
|
87 |
+
|
88 |
+
/** Returns the caller line number. */
|
89 |
+
public function getLineNumber() {
|
90 |
+
return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber;
|
91 |
+
}
|
92 |
+
|
93 |
+
/** Returns the caller method name. */
|
94 |
+
public function getMethodName() {
|
95 |
+
return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName;
|
96 |
+
}
|
97 |
+
|
98 |
+
/** Returns the full information of the caller. */
|
99 |
+
public function getFullInfo() {
|
100 |
+
return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerLoggingEvent.php
RENAMED
@@ -1,362 +1,368 @@
|
|
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 |
-
/**
|
22 |
-
* The internal representation of logging event.
|
23 |
-
*
|
24 |
-
* @version $Revision:
|
25 |
-
* @package log4php
|
26 |
-
*/
|
27 |
-
class LoggerLoggingEvent {
|
28 |
-
|
29 |
-
private static $startTime;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @var string Fully Qualified Class Name of the calling category class.
|
33 |
-
*/
|
34 |
-
private $fqcn;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* @var Logger reference
|
38 |
-
*/
|
39 |
-
private $logger
|
40 |
-
|
41 |
-
/**
|
42 |
-
* The category (logger) name.
|
43 |
-
* This field will be marked as private in future
|
44 |
-
* releases. Please do not access it directly.
|
45 |
-
* Use the {@link getLoggerName()} method instead.
|
46 |
-
* @deprecated
|
47 |
-
*/
|
48 |
-
private $categoryName;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Level of the logging event.
|
52 |
-
* @var LoggerLevel
|
53 |
-
*/
|
54 |
-
protected $level;
|
55 |
-
|
56 |
-
/**
|
57 |
-
* The nested diagnostic context (NDC) of logging event.
|
58 |
-
* @var string
|
59 |
-
*/
|
60 |
-
private $ndc;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Have we tried to do an NDC lookup? If we did, there is no need
|
64 |
-
* to do it again. Note that its value is always false when
|
65 |
-
* serialized. Thus, a receiving SocketNode will never use it's own
|
66 |
-
* (incorrect) NDC. See also writeObject method.
|
67 |
-
* @var boolean
|
68 |
-
*/
|
69 |
-
private $ndcLookupRequired = true;
|
70 |
-
|
71 |
-
/**
|
72 |
-
*
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
*
|
86 |
-
*
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
*
|
117 |
-
*
|
118 |
-
*
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
$this->
|
130 |
-
if($
|
131 |
-
$this->
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
/**
|
150 |
-
*
|
151 |
-
*
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
}
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
$prevHop
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
*
|
208 |
-
* @return
|
209 |
-
*/
|
210 |
-
public function
|
211 |
-
return $this->
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Return the name of the logger. Use this form instead of directly
|
216 |
-
* accessing the {@link $categoryName} field.
|
217 |
-
* @return string
|
218 |
-
*/
|
219 |
-
public function getLoggerName() {
|
220 |
-
return $this->categoryName;
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Return the message for this logging event.
|
225 |
-
*
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
return $
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* Returns the
|
257 |
-
*
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
*
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
*
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
*
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
'
|
354 |
-
'
|
355 |
-
'
|
356 |
-
'
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* The internal representation of logging event.
|
23 |
+
*
|
24 |
+
* @version $Revision: 1382273 $
|
25 |
+
* @package log4php
|
26 |
+
*/
|
27 |
+
class LoggerLoggingEvent {
|
28 |
+
|
29 |
+
private static $startTime;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @var string Fully Qualified Class Name of the calling category class.
|
33 |
+
*/
|
34 |
+
private $fqcn;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var Logger reference
|
38 |
+
*/
|
39 |
+
private $logger;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* The category (logger) name.
|
43 |
+
* This field will be marked as private in future
|
44 |
+
* releases. Please do not access it directly.
|
45 |
+
* Use the {@link getLoggerName()} method instead.
|
46 |
+
* @deprecated
|
47 |
+
*/
|
48 |
+
private $categoryName;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Level of the logging event.
|
52 |
+
* @var LoggerLevel
|
53 |
+
*/
|
54 |
+
protected $level;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* The nested diagnostic context (NDC) of logging event.
|
58 |
+
* @var string
|
59 |
+
*/
|
60 |
+
private $ndc;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Have we tried to do an NDC lookup? If we did, there is no need
|
64 |
+
* to do it again. Note that its value is always false when
|
65 |
+
* serialized. Thus, a receiving SocketNode will never use it's own
|
66 |
+
* (incorrect) NDC. See also writeObject method.
|
67 |
+
* @var boolean
|
68 |
+
*/
|
69 |
+
private $ndcLookupRequired = true;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @var mixed The application supplied message of logging event.
|
73 |
+
*/
|
74 |
+
private $message;
|
75 |
+
|
76 |
+
/**
|
77 |
+
* The application supplied message rendered through the log4php
|
78 |
+
* objet rendering mechanism. At present renderedMessage == message.
|
79 |
+
* @var string
|
80 |
+
*/
|
81 |
+
private $renderedMessage;
|
82 |
+
|
83 |
+
/**
|
84 |
+
* The name of thread in which this logging event was generated.
|
85 |
+
* log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()}
|
86 |
+
* @var mixed
|
87 |
+
*/
|
88 |
+
private $threadName;
|
89 |
+
|
90 |
+
/**
|
91 |
+
* The number of seconds elapsed from 1/1/1970 until logging event
|
92 |
+
* was created plus microseconds if available.
|
93 |
+
* @var float
|
94 |
+
*/
|
95 |
+
public $timeStamp;
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @var LoggerLocationInfo Location information for the caller.
|
99 |
+
*/
|
100 |
+
private $locationInfo;
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @var LoggerThrowableInformation log4php internal representation of throwable
|
104 |
+
*/
|
105 |
+
private $throwableInfo;
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Instantiate a LoggingEvent from the supplied parameters.
|
109 |
+
*
|
110 |
+
* Except {@link $timeStamp} all the other fields of
|
111 |
+
* LoggerLoggingEvent are filled when actually needed.
|
112 |
+
*
|
113 |
+
* @param string $fqcn name of the caller class.
|
114 |
+
* @param mixed $logger The {@link Logger} category of this event or the logger name.
|
115 |
+
* @param LoggerLevel $level The level of this event.
|
116 |
+
* @param mixed $message The message of this event.
|
117 |
+
* @param integer $timeStamp the timestamp of this logging event.
|
118 |
+
* @param Exception $throwable The throwable associated with logging event
|
119 |
+
*/
|
120 |
+
public function __construct($fqcn, $logger, LoggerLevel $level, $message, $timeStamp = null, $throwable = null) {
|
121 |
+
$this->fqcn = $fqcn;
|
122 |
+
if($logger instanceof Logger) {
|
123 |
+
$this->logger = $logger;
|
124 |
+
$this->categoryName = $logger->getName();
|
125 |
+
} else {
|
126 |
+
$this->categoryName = strval($logger);
|
127 |
+
}
|
128 |
+
$this->level = $level;
|
129 |
+
$this->message = $message;
|
130 |
+
if($timeStamp !== null && is_numeric($timeStamp)) {
|
131 |
+
$this->timeStamp = $timeStamp;
|
132 |
+
} else {
|
133 |
+
$this->timeStamp = microtime(true);
|
134 |
+
}
|
135 |
+
|
136 |
+
if ($throwable !== null && $throwable instanceof Exception) {
|
137 |
+
$this->throwableInfo = new LoggerThrowableInformation($throwable);
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Returns the full qualified classname.
|
143 |
+
* TODO: PHP does contain namespaces in 5.3. Those should be returned too,
|
144 |
+
*/
|
145 |
+
public function getFullQualifiedClassname() {
|
146 |
+
return $this->fqcn;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Set the location information for this logging event. The collected
|
151 |
+
* information is cached for future use.
|
152 |
+
*
|
153 |
+
* <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
|
154 |
+
* to collect informations about caller.</p>
|
155 |
+
* <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
|
156 |
+
* @return LoggerLocationInfo
|
157 |
+
*/
|
158 |
+
public function getLocationInformation() {
|
159 |
+
if($this->locationInfo === null) {
|
160 |
+
|
161 |
+
$locationInfo = array();
|
162 |
+
$trace = debug_backtrace();
|
163 |
+
$prevHop = null;
|
164 |
+
// make a downsearch to identify the caller
|
165 |
+
$hop = array_pop($trace);
|
166 |
+
while($hop !== null) {
|
167 |
+
if(isset($hop['class'])) {
|
168 |
+
// we are sometimes in functions = no class available: avoid php warning here
|
169 |
+
$className = strtolower($hop['class']);
|
170 |
+
if(!empty($className) and ($className == 'logger' or
|
171 |
+
strtolower(get_parent_class($className)) == 'logger')) {
|
172 |
+
$locationInfo['line'] = $hop['line'];
|
173 |
+
$locationInfo['file'] = $hop['file'];
|
174 |
+
break;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
$prevHop = $hop;
|
178 |
+
$hop = array_pop($trace);
|
179 |
+
}
|
180 |
+
$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
|
181 |
+
if(isset($prevHop['function']) and
|
182 |
+
$prevHop['function'] !== 'include' and
|
183 |
+
$prevHop['function'] !== 'include_once' and
|
184 |
+
$prevHop['function'] !== 'require' and
|
185 |
+
$prevHop['function'] !== 'require_once') {
|
186 |
+
|
187 |
+
$locationInfo['function'] = $prevHop['function'];
|
188 |
+
} else {
|
189 |
+
$locationInfo['function'] = 'main';
|
190 |
+
}
|
191 |
+
|
192 |
+
$this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn);
|
193 |
+
}
|
194 |
+
return $this->locationInfo;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Return the level of this event. Use this form instead of directly
|
199 |
+
* accessing the {@link $level} field.
|
200 |
+
* @return LoggerLevel
|
201 |
+
*/
|
202 |
+
public function getLevel() {
|
203 |
+
return $this->level;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Returns the logger which created the event.
|
208 |
+
* @return Logger
|
209 |
+
*/
|
210 |
+
public function getLogger() {
|
211 |
+
return $this->logger;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Return the name of the logger. Use this form instead of directly
|
216 |
+
* accessing the {@link $categoryName} field.
|
217 |
+
* @return string
|
218 |
+
*/
|
219 |
+
public function getLoggerName() {
|
220 |
+
return $this->categoryName;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Return the message for this logging event.
|
225 |
+
* @return mixed
|
226 |
+
*/
|
227 |
+
public function getMessage() {
|
228 |
+
return $this->message;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* This method returns the NDC for this event. It will return the
|
233 |
+
* correct content even if the event was generated in a different
|
234 |
+
* thread or even on a different machine. The {@link LoggerNDC::get()} method
|
235 |
+
* should <b>never</b> be called directly.
|
236 |
+
* @return string
|
237 |
+
*/
|
238 |
+
public function getNDC() {
|
239 |
+
if($this->ndcLookupRequired) {
|
240 |
+
$this->ndcLookupRequired = false;
|
241 |
+
$this->ndc = LoggerNDC::get();
|
242 |
+
}
|
243 |
+
return $this->ndc;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Returns the the context corresponding to the <code>key</code>
|
248 |
+
* parameter.
|
249 |
+
* @return string
|
250 |
+
*/
|
251 |
+
public function getMDC($key) {
|
252 |
+
return LoggerMDC::get($key);
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Returns the entire MDC context.
|
257 |
+
* @return array
|
258 |
+
*/
|
259 |
+
public function getMDCMap () {
|
260 |
+
return LoggerMDC::getMap();
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Render message.
|
265 |
+
* @return string
|
266 |
+
*/
|
267 |
+
public function getRenderedMessage() {
|
268 |
+
if($this->renderedMessage === null and $this->message !== null) {
|
269 |
+
if(is_string($this->message)) {
|
270 |
+
$this->renderedMessage = $this->message;
|
271 |
+
} else {
|
272 |
+
$rendererMap = Logger::getHierarchy()->getRendererMap();
|
273 |
+
$this->renderedMessage= $rendererMap->findAndRender($this->message);
|
274 |
+
}
|
275 |
+
}
|
276 |
+
return $this->renderedMessage;
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Returns the time when the application started, as a UNIX timestamp
|
281 |
+
* with microseconds.
|
282 |
+
* @return float
|
283 |
+
*/
|
284 |
+
public static function getStartTime() {
|
285 |
+
if(!isset(self::$startTime)) {
|
286 |
+
self::$startTime = microtime(true);
|
287 |
+
}
|
288 |
+
return self::$startTime;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* @return float
|
293 |
+
*/
|
294 |
+
public function getTimeStamp() {
|
295 |
+
return $this->timeStamp;
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Returns the time in seconds passed from the beginning of execution to
|
300 |
+
* the time the event was constructed.
|
301 |
+
*
|
302 |
+
* @return float Seconds with microseconds in decimals.
|
303 |
+
*/
|
304 |
+
public function getRelativeTime() {
|
305 |
+
return $this->timeStamp - self::$startTime;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Returns the time in milliseconds passed from the beginning of execution
|
310 |
+
* to the time the event was constructed.
|
311 |
+
*
|
312 |
+
* @deprecated This method has been replaced by getRelativeTime which
|
313 |
+
* does not perform unneccesary multiplication and formatting.
|
314 |
+
*
|
315 |
+
* @return integer
|
316 |
+
*/
|
317 |
+
public function getTime() {
|
318 |
+
$eventTime = $this->getTimeStamp();
|
319 |
+
$eventStartTime = LoggerLoggingEvent::getStartTime();
|
320 |
+
return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* @return mixed
|
325 |
+
*/
|
326 |
+
public function getThreadName() {
|
327 |
+
if ($this->threadName === null) {
|
328 |
+
$this->threadName = (string)getmypid();
|
329 |
+
}
|
330 |
+
return $this->threadName;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* @return mixed LoggerThrowableInformation
|
335 |
+
*/
|
336 |
+
public function getThrowableInformation() {
|
337 |
+
return $this->throwableInfo;
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Serialize this object
|
342 |
+
* @return string
|
343 |
+
*/
|
344 |
+
public function toString() {
|
345 |
+
serialize($this);
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Avoid serialization of the {@link $logger} object
|
350 |
+
*/
|
351 |
+
public function __sleep() {
|
352 |
+
return array(
|
353 |
+
'fqcn',
|
354 |
+
'categoryName',
|
355 |
+
'level',
|
356 |
+
'ndc',
|
357 |
+
'ndcLookupRequired',
|
358 |
+
'message',
|
359 |
+
'renderedMessage',
|
360 |
+
'threadName',
|
361 |
+
'timeStamp',
|
362 |
+
'locationInfo',
|
363 |
+
);
|
364 |
+
}
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
LoggerLoggingEvent::getStartTime();
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerMDC.php
RENAMED
@@ -1,118 +1,88 @@
|
|
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 |
-
/**
|
22 |
-
* The LoggerMDC class provides
|
23 |
-
*
|
24 |
-
* A
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
* This class is similar to the {@link LoggerNDC} class except that
|
30 |
-
* it is based on a map instead of a stack.
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
/**
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
*
|
57 |
-
*
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
*
|
73 |
-
*
|
74 |
-
*
|
75 |
-
*
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
}
|
90 |
-
return '';
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Returns the contex map as an array.
|
95 |
-
* @return array The MDC context map.
|
96 |
-
*/
|
97 |
-
public static function getMap() {
|
98 |
-
return self::$map;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Removes the the context identified by the key parameter.
|
103 |
-
*
|
104 |
-
* Only affects user mappings, not $_ENV or $_SERVER.
|
105 |
-
*
|
106 |
-
* @param string $key The key to be removed.
|
107 |
-
*/
|
108 |
-
public static function remove($key) {
|
109 |
-
unset(self::$map[$key]);
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Clears the mapped diagnostic context.
|
114 |
-
*/
|
115 |
-
public static function clear() {
|
116 |
-
self::$map = array();
|
117 |
-
}
|
118 |
-
}
|
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 |
+
/**
|
22 |
+
* The LoggerMDC class provides _mapped diagnostic contexts_.
|
23 |
+
*
|
24 |
+
* A Mapped Diagnostic Context, or MDC in short, is an instrument for
|
25 |
+
* distinguishing interleaved log output from different sources. Log output
|
26 |
+
* is typically interleaved when a server handles multiple clients
|
27 |
+
* near-simultaneously.
|
28 |
+
*
|
29 |
+
* This class is similar to the {@link LoggerNDC} class except that
|
30 |
+
* it is based on a map instead of a stack.
|
31 |
+
*
|
32 |
+
* @version $Revision: 1343630 $
|
33 |
+
* @since 0.3
|
34 |
+
* @package log4php
|
35 |
+
*/
|
36 |
+
class LoggerMDC {
|
37 |
+
|
38 |
+
/** Holds the context map. */
|
39 |
+
private static $map = array();
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Stores a context value as identified with the key parameter into the
|
43 |
+
* context map.
|
44 |
+
*
|
45 |
+
* @param string $key the key
|
46 |
+
* @param string $value the value
|
47 |
+
*/
|
48 |
+
public static function put($key, $value) {
|
49 |
+
self::$map[$key] = $value;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Returns the context value identified by the key parameter.
|
54 |
+
*
|
55 |
+
* @param string $key The key.
|
56 |
+
* @return string The context or an empty string if no context found
|
57 |
+
* for given key.
|
58 |
+
*/
|
59 |
+
public static function get($key) {
|
60 |
+
return isset(self::$map[$key]) ? self::$map[$key] : '';
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Returns the contex map as an array.
|
65 |
+
* @return array The MDC context map.
|
66 |
+
*/
|
67 |
+
public static function getMap() {
|
68 |
+
return self::$map;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Removes the the context identified by the key parameter.
|
73 |
+
*
|
74 |
+
* Only affects user mappings, not $_ENV or $_SERVER.
|
75 |
+
*
|
76 |
+
* @param string $key The key to be removed.
|
77 |
+
*/
|
78 |
+
public static function remove($key) {
|
79 |
+
unset(self::$map[$key]);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Clears the mapped diagnostic context.
|
84 |
+
*/
|
85 |
+
public static function clear() {
|
86 |
+
self::$map = array();
|
87 |
+
}
|
88 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerNDC.php
RENAMED
@@ -1,203 +1,203 @@
|
|
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 |
-
/**
|
22 |
-
* The NDC class implements <i>nested diagnostic contexts</i>.
|
23 |
-
*
|
24 |
-
* NDC was defined by Neil Harrison in the article "Patterns for Logging
|
25 |
-
* Diagnostic Messages" part of the book <i>"Pattern Languages of
|
26 |
-
* Program Design 3"</i> edited by Martin et al.
|
27 |
-
*
|
28 |
-
* A Nested Diagnostic Context, or NDC in short, is an instrument
|
29 |
-
* to distinguish interleaved log output from different sources. Log
|
30 |
-
* output is typically interleaved when a server handles multiple
|
31 |
-
* clients near-simultaneously.
|
32 |
-
*
|
33 |
-
* This class is similar to the {@link LoggerMDC} class except that it is
|
34 |
-
* based on a stack instead of a map.
|
35 |
-
*
|
36 |
-
* Interleaved log output can still be meaningful if each log entry
|
37 |
-
* from different contexts had a distinctive stamp. This is where NDCs
|
38 |
-
* come into play.
|
39 |
-
*
|
40 |
-
* <b>Note that NDCs are managed on a per thread basis</b>.
|
41 |
-
*
|
42 |
-
* NDC operations such as {@link push()}, {@link pop()},
|
43 |
-
* {@link clear()}, {@link getDepth()} and {@link setMaxDepth()}
|
44 |
-
* affect the NDC of the <i>current</i> thread only. NDCs of other
|
45 |
-
* threads remain unaffected.
|
46 |
-
*
|
47 |
-
* For example, a servlet can build a per client request NDC
|
48 |
-
* consisting the clients host name and other information contained in
|
49 |
-
* the the request. <i>Cookies</i> are another source of distinctive
|
50 |
-
* information. To build an NDC one uses the {@link push()}
|
51 |
-
* operation.
|
52 |
-
*
|
53 |
-
* Simply put,
|
54 |
-
*
|
55 |
-
* - Contexts can be nested.
|
56 |
-
* - When entering a context, call <kbd>LoggerNDC::push()</kbd>
|
57 |
-
* As a side effect, if there is no nested diagnostic context for the
|
58 |
-
* current thread, this method will create it.
|
59 |
-
* - When leaving a context, call <kbd>LoggerNDC::pop()</kbd>
|
60 |
-
* - <b>When exiting a thread make sure to call {@link remove()}</b>
|
61 |
-
*
|
62 |
-
* There is no penalty for forgetting to match each
|
63 |
-
* <kbd>push</kbd> operation with a corresponding <kbd>pop</kbd>,
|
64 |
-
* except the obvious mismatch between the real application context
|
65 |
-
* and the context set in the NDC.
|
66 |
-
*
|
67 |
-
* If configured to do so, {@link LoggerPatternLayout} and {@link LoggerLayoutTTCC}
|
68 |
-
* instances automatically retrieve the nested diagnostic
|
69 |
-
* context for the current thread without any user intervention.
|
70 |
-
* Hence, even if a servlet is serving multiple clients
|
71 |
-
* simultaneously, the logs emanating from the same code (belonging to
|
72 |
-
* the same category) can still be distinguished because each client
|
73 |
-
* request will have a different NDC tag.
|
74 |
-
*
|
75 |
-
* Example:
|
76 |
-
*
|
77 |
-
* {@example ../../examples/php/ndc.php 19}<br>
|
78 |
-
*
|
79 |
-
* With the properties file:
|
80 |
-
*
|
81 |
-
* {@example ../../examples/resources/ndc.properties 18}<br>
|
82 |
-
*
|
83 |
-
* Will result in the following (notice the conn and client ids):
|
84 |
-
*
|
85 |
-
* <pre>
|
86 |
-
* 2009-09-13 19:04:27 DEBUG root conn=1234: just received a new connection in src/examples/php/ndc.php at 23
|
87 |
-
* 2009-09-13 19:04:27 DEBUG root conn=1234 client=ab23: some more messages that can in src/examples/php/ndc.php at 25
|
88 |
-
* 2009-09-13 19:04:27 DEBUG root conn=1234 client=ab23: now related to a client in src/examples/php/ndc.php at 26
|
89 |
-
* 2009-09-13 19:04:27 DEBUG root : back and waiting for new connections in src/examples/php/ndc.php at 29
|
90 |
-
* </pre>
|
91 |
-
*
|
92 |
-
* @version $Revision:
|
93 |
-
* @package log4php
|
94 |
-
* @since 0.3
|
95 |
-
*/
|
96 |
-
class LoggerNDC {
|
97 |
-
|
98 |
-
/** This is the repository of NDC stack */
|
99 |
-
private static $stack = array();
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Clear any nested diagnostic information if any. This method is
|
103 |
-
* useful in cases where the same thread can be potentially used
|
104 |
-
* over and over in different unrelated contexts.
|
105 |
-
*
|
106 |
-
* <p>This method is equivalent to calling the {@link setMaxDepth()}
|
107 |
-
* method with a zero <var>maxDepth</var> argument.
|
108 |
-
*/
|
109 |
-
public static function clear() {
|
110 |
-
self::$stack = array();
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Never use this method directly, use the {@link LoggerLoggingEvent::getNDC()} method instead.
|
115 |
-
* @return array
|
116 |
-
*/
|
117 |
-
public static function get() {
|
118 |
-
return implode(' ', self::$stack);
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Get the current nesting depth of this diagnostic context.
|
123 |
-
*
|
124 |
-
* @see setMaxDepth()
|
125 |
-
* @return integer
|
126 |
-
*/
|
127 |
-
public static function getDepth() {
|
128 |
-
return count(self::$stack);
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Clients should call this method before leaving a diagnostic
|
133 |
-
* context.
|
134 |
-
*
|
135 |
-
* <p>The returned value is the value that was pushed last. If no
|
136 |
-
* context is available, then the empty string "" is returned.</p>
|
137 |
-
*
|
138 |
-
* @return string The innermost diagnostic context.
|
139 |
-
*/
|
140 |
-
public static function pop() {
|
141 |
-
if(count(self::$stack) > 0) {
|
142 |
-
return array_pop(self::$stack);
|
143 |
-
} else {
|
144 |
-
return '';
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Looks at the last diagnostic context at the top of this NDC
|
150 |
-
* without removing it.
|
151 |
-
*
|
152 |
-
* <p>The returned value is the value that was pushed last. If no
|
153 |
-
* context is available, then the empty string "" is returned.</p>
|
154 |
-
* @return string The innermost diagnostic context.
|
155 |
-
*/
|
156 |
-
public static function peek(){
|
157 |
-
if(count(self::$stack) > 0) {
|
158 |
-
return end(self::$stack);
|
159 |
-
} else {
|
160 |
-
return '';
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Push new diagnostic context information for the current thread.
|
166 |
-
*
|
167 |
-
* <p>The contents of the <var>message</var> parameter is
|
168 |
-
* determined solely by the client.
|
169 |
-
*
|
170 |
-
* @param string $message The new diagnostic context information.
|
171 |
-
*/
|
172 |
-
public static function push($message) {
|
173 |
-
array_push(self::$stack, (string)$message);
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Remove the diagnostic context for this thread.
|
178 |
-
*/
|
179 |
-
public static function remove() {
|
180 |
-
LoggerNDC::clear();
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Set maximum depth of this diagnostic context. If the current
|
185 |
-
* depth is smaller or equal to <var>maxDepth</var>, then no
|
186 |
-
* action is taken.
|
187 |
-
*
|
188 |
-
* <p>This method is a convenient alternative to multiple
|
189 |
-
* {@link pop()} calls. Moreover, it is often the case that at
|
190 |
-
* the end of complex call sequences, the depth of the NDC is
|
191 |
-
* unpredictable. The {@link setMaxDepth()} method circumvents
|
192 |
-
* this problem.
|
193 |
-
*
|
194 |
-
* @param integer $maxDepth
|
195 |
-
* @see getDepth()
|
196 |
-
*/
|
197 |
-
public static function setMaxDepth($maxDepth) {
|
198 |
-
$maxDepth = (int)$maxDepth;
|
199 |
-
if(LoggerNDC::getDepth() > $maxDepth) {
|
200 |
-
self::$stack = array_slice(self::$stack, 0, $maxDepth);
|
201 |
-
}
|
202 |
-
}
|
203 |
-
}
|
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 |
+
/**
|
22 |
+
* The NDC class implements <i>nested diagnostic contexts</i>.
|
23 |
+
*
|
24 |
+
* NDC was defined by Neil Harrison in the article "Patterns for Logging
|
25 |
+
* Diagnostic Messages" part of the book <i>"Pattern Languages of
|
26 |
+
* Program Design 3"</i> edited by Martin et al.
|
27 |
+
*
|
28 |
+
* A Nested Diagnostic Context, or NDC in short, is an instrument
|
29 |
+
* to distinguish interleaved log output from different sources. Log
|
30 |
+
* output is typically interleaved when a server handles multiple
|
31 |
+
* clients near-simultaneously.
|
32 |
+
*
|
33 |
+
* This class is similar to the {@link LoggerMDC} class except that it is
|
34 |
+
* based on a stack instead of a map.
|
35 |
+
*
|
36 |
+
* Interleaved log output can still be meaningful if each log entry
|
37 |
+
* from different contexts had a distinctive stamp. This is where NDCs
|
38 |
+
* come into play.
|
39 |
+
*
|
40 |
+
* <b>Note that NDCs are managed on a per thread basis</b>.
|
41 |
+
*
|
42 |
+
* NDC operations such as {@link push()}, {@link pop()},
|
43 |
+
* {@link clear()}, {@link getDepth()} and {@link setMaxDepth()}
|
44 |
+
* affect the NDC of the <i>current</i> thread only. NDCs of other
|
45 |
+
* threads remain unaffected.
|
46 |
+
*
|
47 |
+
* For example, a servlet can build a per client request NDC
|
48 |
+
* consisting the clients host name and other information contained in
|
49 |
+
* the the request. <i>Cookies</i> are another source of distinctive
|
50 |
+
* information. To build an NDC one uses the {@link push()}
|
51 |
+
* operation.
|
52 |
+
*
|
53 |
+
* Simply put,
|
54 |
+
*
|
55 |
+
* - Contexts can be nested.
|
56 |
+
* - When entering a context, call <kbd>LoggerNDC::push()</kbd>
|
57 |
+
* As a side effect, if there is no nested diagnostic context for the
|
58 |
+
* current thread, this method will create it.
|
59 |
+
* - When leaving a context, call <kbd>LoggerNDC::pop()</kbd>
|
60 |
+
* - <b>When exiting a thread make sure to call {@link remove()}</b>
|
61 |
+
*
|
62 |
+
* There is no penalty for forgetting to match each
|
63 |
+
* <kbd>push</kbd> operation with a corresponding <kbd>pop</kbd>,
|
64 |
+
* except the obvious mismatch between the real application context
|
65 |
+
* and the context set in the NDC.
|
66 |
+
*
|
67 |
+
* If configured to do so, {@link LoggerPatternLayout} and {@link LoggerLayoutTTCC}
|
68 |
+
* instances automatically retrieve the nested diagnostic
|
69 |
+
* context for the current thread without any user intervention.
|
70 |
+
* Hence, even if a servlet is serving multiple clients
|
71 |
+
* simultaneously, the logs emanating from the same code (belonging to
|
72 |
+
* the same category) can still be distinguished because each client
|
73 |
+
* request will have a different NDC tag.
|
74 |
+
*
|
75 |
+
* Example:
|
76 |
+
*
|
77 |
+
* {@example ../../examples/php/ndc.php 19}<br>
|
78 |
+
*
|
79 |
+
* With the properties file:
|
80 |
+
*
|
81 |
+
* {@example ../../examples/resources/ndc.properties 18}<br>
|
82 |
+
*
|
83 |
+
* Will result in the following (notice the conn and client ids):
|
84 |
+
*
|
85 |
+
* <pre>
|
86 |
+
* 2009-09-13 19:04:27 DEBUG root conn=1234: just received a new connection in src/examples/php/ndc.php at 23
|
87 |
+
* 2009-09-13 19:04:27 DEBUG root conn=1234 client=ab23: some more messages that can in src/examples/php/ndc.php at 25
|
88 |
+
* 2009-09-13 19:04:27 DEBUG root conn=1234 client=ab23: now related to a client in src/examples/php/ndc.php at 26
|
89 |
+
* 2009-09-13 19:04:27 DEBUG root : back and waiting for new connections in src/examples/php/ndc.php at 29
|
90 |
+
* </pre>
|
91 |
+
*
|
92 |
+
* @version $Revision: 1350602 $
|
93 |
+
* @package log4php
|
94 |
+
* @since 0.3
|
95 |
+
*/
|
96 |
+
class LoggerNDC {
|
97 |
+
|
98 |
+
/** This is the repository of NDC stack */
|
99 |
+
private static $stack = array();
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Clear any nested diagnostic information if any. This method is
|
103 |
+
* useful in cases where the same thread can be potentially used
|
104 |
+
* over and over in different unrelated contexts.
|
105 |
+
*
|
106 |
+
* <p>This method is equivalent to calling the {@link setMaxDepth()}
|
107 |
+
* method with a zero <var>maxDepth</var> argument.
|
108 |
+
*/
|
109 |
+
public static function clear() {
|
110 |
+
self::$stack = array();
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Never use this method directly, use the {@link LoggerLoggingEvent::getNDC()} method instead.
|
115 |
+
* @return array
|
116 |
+
*/
|
117 |
+
public static function get() {
|
118 |
+
return implode(' ', self::$stack);
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Get the current nesting depth of this diagnostic context.
|
123 |
+
*
|
124 |
+
* @see setMaxDepth()
|
125 |
+
* @return integer
|
126 |
+
*/
|
127 |
+
public static function getDepth() {
|
128 |
+
return count(self::$stack);
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Clients should call this method before leaving a diagnostic
|
133 |
+
* context.
|
134 |
+
*
|
135 |
+
* <p>The returned value is the value that was pushed last. If no
|
136 |
+
* context is available, then the empty string "" is returned.</p>
|
137 |
+
*
|
138 |
+
* @return string The innermost diagnostic context.
|
139 |
+
*/
|
140 |
+
public static function pop() {
|
141 |
+
if(count(self::$stack) > 0) {
|
142 |
+
return array_pop(self::$stack);
|
143 |
+
} else {
|
144 |
+
return '';
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Looks at the last diagnostic context at the top of this NDC
|
150 |
+
* without removing it.
|
151 |
+
*
|
152 |
+
* <p>The returned value is the value that was pushed last. If no
|
153 |
+
* context is available, then the empty string "" is returned.</p>
|
154 |
+
* @return string The innermost diagnostic context.
|
155 |
+
*/
|
156 |
+
public static function peek() {
|
157 |
+
if(count(self::$stack) > 0) {
|
158 |
+
return end(self::$stack);
|
159 |
+
} else {
|
160 |
+
return '';
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Push new diagnostic context information for the current thread.
|
166 |
+
*
|
167 |
+
* <p>The contents of the <var>message</var> parameter is
|
168 |
+
* determined solely by the client.
|
169 |
+
*
|
170 |
+
* @param string $message The new diagnostic context information.
|
171 |
+
*/
|
172 |
+
public static function push($message) {
|
173 |
+
array_push(self::$stack, (string)$message);
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Remove the diagnostic context for this thread.
|
178 |
+
*/
|
179 |
+
public static function remove() {
|
180 |
+
LoggerNDC::clear();
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Set maximum depth of this diagnostic context. If the current
|
185 |
+
* depth is smaller or equal to <var>maxDepth</var>, then no
|
186 |
+
* action is taken.
|
187 |
+
*
|
188 |
+
* <p>This method is a convenient alternative to multiple
|
189 |
+
* {@link pop()} calls. Moreover, it is often the case that at
|
190 |
+
* the end of complex call sequences, the depth of the NDC is
|
191 |
+
* unpredictable. The {@link setMaxDepth()} method circumvents
|
192 |
+
* this problem.
|
193 |
+
*
|
194 |
+
* @param integer $maxDepth
|
195 |
+
* @see getDepth()
|
196 |
+
*/
|
197 |
+
public static function setMaxDepth($maxDepth) {
|
198 |
+
$maxDepth = (int)$maxDepth;
|
199 |
+
if(LoggerNDC::getDepth() > $maxDepth) {
|
200 |
+
self::$stack = array_slice(self::$stack, 0, $maxDepth);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerReflectionUtils.php
RENAMED
@@ -1,153 +1,152 @@
|
|
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 |
-
/**
|
22 |
-
* Provides methods for reflective use on php objects
|
23 |
-
* @package log4php
|
24 |
-
*/
|
25 |
-
class LoggerReflectionUtils {
|
26 |
-
/** the target object */
|
27 |
-
private $obj;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Create a new LoggerReflectionUtils for the specified Object.
|
31 |
-
* This is done in prepartion for invoking {@link setProperty()}
|
32 |
-
* one or more times.
|
33 |
-
* @param object &$obj the object for which to set properties
|
34 |
-
*/
|
35 |
-
public function __construct($obj) {
|
36 |
-
$this->obj = $obj;
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Set the properties of an object passed as a parameter in one
|
41 |
-
* go. The <code>properties</code> are parsed relative to a
|
42 |
-
* <code>prefix</code>.
|
43 |
-
*
|
44 |
-
* @param object $obj The object to configure.
|
45 |
-
* @param array $properties An array containing keys and values.
|
46 |
-
* @param string $prefix Only keys having the specified prefix will be set.
|
47 |
-
*/
|
48 |
-
// TODO: check, if this is really useful
|
49 |
-
public static function setPropertiesByObject($obj, $properties, $prefix) {
|
50 |
-
$pSetter = new LoggerReflectionUtils($obj);
|
51 |
-
return $pSetter->setProperties($properties, $prefix);
|
52 |
-
}
|
53 |
-
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Set the properites for the object that match the
|
57 |
-
* <code>prefix</code> passed as parameter.
|
58 |
-
*
|
59 |
-
* Example:
|
60 |
-
*
|
61 |
-
* $arr['xxxname'] = 'Joe';
|
62 |
-
* $arr['xxxmale'] = true;
|
63 |
-
* and prefix xxx causes setName and setMale.
|
64 |
-
*
|
65 |
-
* @param array $properties An array containing keys and values.
|
66 |
-
* @param string $prefix Only keys having the specified prefix will be set.
|
67 |
-
*/
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
$
|
78 |
-
$key
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
*
|
90 |
-
*
|
91 |
-
*
|
92 |
-
*
|
93 |
-
*
|
94 |
-
*
|
95 |
-
*
|
96 |
-
*
|
97 |
-
*
|
98 |
-
*
|
99 |
-
*
|
100 |
-
* @param string $
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
*
|
125 |
-
*
|
126 |
-
* @
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
* @param
|
138 |
-
* @param
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
}
|
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 |
+
/**
|
22 |
+
* Provides methods for reflective use on php objects
|
23 |
+
* @package log4php
|
24 |
+
*/
|
25 |
+
class LoggerReflectionUtils {
|
26 |
+
/** the target object */
|
27 |
+
private $obj;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Create a new LoggerReflectionUtils for the specified Object.
|
31 |
+
* This is done in prepartion for invoking {@link setProperty()}
|
32 |
+
* one or more times.
|
33 |
+
* @param object &$obj the object for which to set properties
|
34 |
+
*/
|
35 |
+
public function __construct($obj) {
|
36 |
+
$this->obj = $obj;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Set the properties of an object passed as a parameter in one
|
41 |
+
* go. The <code>properties</code> are parsed relative to a
|
42 |
+
* <code>prefix</code>.
|
43 |
+
*
|
44 |
+
* @param object $obj The object to configure.
|
45 |
+
* @param array $properties An array containing keys and values.
|
46 |
+
* @param string $prefix Only keys having the specified prefix will be set.
|
47 |
+
*/
|
48 |
+
// TODO: check, if this is really useful
|
49 |
+
public static function setPropertiesByObject($obj, $properties, $prefix) {
|
50 |
+
$pSetter = new LoggerReflectionUtils($obj);
|
51 |
+
return $pSetter->setProperties($properties, $prefix);
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Set the properites for the object that match the
|
57 |
+
* <code>prefix</code> passed as parameter.
|
58 |
+
*
|
59 |
+
* Example:
|
60 |
+
*
|
61 |
+
* $arr['xxxname'] = 'Joe';
|
62 |
+
* $arr['xxxmale'] = true;
|
63 |
+
* and prefix xxx causes setName and setMale.
|
64 |
+
*
|
65 |
+
* @param array $properties An array containing keys and values.
|
66 |
+
* @param string $prefix Only keys having the specified prefix will be set.
|
67 |
+
*/
|
68 |
+
public function setProperties($properties, $prefix) {
|
69 |
+
$len = strlen($prefix);
|
70 |
+
reset($properties);
|
71 |
+
while(list($key,) = each($properties)) {
|
72 |
+
if(strpos($key, $prefix) === 0) {
|
73 |
+
if(strpos($key, '.', ($len + 1)) > 0) {
|
74 |
+
continue;
|
75 |
+
}
|
76 |
+
$value = $properties[$key];
|
77 |
+
$key = substr($key, $len);
|
78 |
+
if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
|
79 |
+
continue;
|
80 |
+
}
|
81 |
+
$this->setProperty($key, $value);
|
82 |
+
}
|
83 |
+
}
|
84 |
+
$this->activate();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Set a property on this PropertySetter's Object. If successful, this
|
89 |
+
* method will invoke a setter method on the underlying Object. The
|
90 |
+
* setter is the one for the specified property name and the value is
|
91 |
+
* determined partly from the setter argument type and partly from the
|
92 |
+
* value specified in the call to this method.
|
93 |
+
*
|
94 |
+
* <p>If the setter expects a String no conversion is necessary.
|
95 |
+
* If it expects an int, then an attempt is made to convert 'value'
|
96 |
+
* to an int using new Integer(value). If the setter expects a boolean,
|
97 |
+
* the conversion is by new Boolean(value).
|
98 |
+
*
|
99 |
+
* @param string $name name of the property
|
100 |
+
* @param string $value String value of the property
|
101 |
+
*/
|
102 |
+
public function setProperty($name, $value) {
|
103 |
+
if($value === null) {
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
|
107 |
+
$method = "set" . ucfirst($name);
|
108 |
+
|
109 |
+
if(!method_exists($this->obj, $method)) {
|
110 |
+
throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
|
111 |
+
} else {
|
112 |
+
return call_user_func(array($this->obj, $method), $value);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
public function activate() {
|
117 |
+
if(method_exists($this->obj, 'activateoptions')) {
|
118 |
+
return call_user_func(array($this->obj, 'activateoptions'));
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Creates an instances from the given class name.
|
124 |
+
*
|
125 |
+
* @param string $classname
|
126 |
+
* @return an object from the class with the given classname
|
127 |
+
*/
|
128 |
+
public static function createObject($class) {
|
129 |
+
if(!empty($class)) {
|
130 |
+
return new $class();
|
131 |
+
}
|
132 |
+
return null;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @param object $object
|
137 |
+
* @param string $name
|
138 |
+
* @param mixed $value
|
139 |
+
*/
|
140 |
+
public static function setter($object, $name, $value) {
|
141 |
+
if (empty($name)) {
|
142 |
+
return false;
|
143 |
+
}
|
144 |
+
$methodName = 'set'.ucfirst($name);
|
145 |
+
if (method_exists($object, $methodName)) {
|
146 |
+
return call_user_func(array($object, $methodName), $value);
|
147 |
+
} else {
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
}
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerRoot.php
RENAMED
@@ -1,70 +1,71 @@
|
|
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 |
-
/**
|
22 |
-
* The root logger.
|
23 |
-
*
|
24 |
-
* @version $Revision:
|
25 |
-
* @package log4php
|
26 |
-
* @see Logger
|
27 |
-
*/
|
28 |
-
class LoggerRoot extends Logger {
|
29 |
-
/**
|
30 |
-
* Constructor
|
31 |
-
*
|
32 |
-
* @param integer $level initial log level
|
33 |
-
*/
|
34 |
-
public function __construct($level = null) {
|
35 |
-
parent::__construct('root');
|
36 |
-
|
37 |
-
if($level == null) {
|
38 |
-
$level = LoggerLevel::getLevelAll();
|
39 |
-
}
|
40 |
-
$this->setLevel($level);
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @return LoggerLevel the level
|
45 |
-
*/
|
46 |
-
public function
|
47 |
-
return
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
*
|
52 |
-
*
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
}
|
|
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 |
+
/**
|
22 |
+
* The root logger.
|
23 |
+
*
|
24 |
+
* @version $Revision: 1343190 $
|
25 |
+
* @package log4php
|
26 |
+
* @see Logger
|
27 |
+
*/
|
28 |
+
class LoggerRoot extends Logger {
|
29 |
+
/**
|
30 |
+
* Constructor
|
31 |
+
*
|
32 |
+
* @param integer $level initial log level
|
33 |
+
*/
|
34 |
+
public function __construct(LoggerLevel $level = null) {
|
35 |
+
parent::__construct('root');
|
36 |
+
|
37 |
+
if($level == null) {
|
38 |
+
$level = LoggerLevel::getLevelAll();
|
39 |
+
}
|
40 |
+
$this->setLevel($level);
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return LoggerLevel the level
|
45 |
+
*/
|
46 |
+
public function getEffectiveLevel() {
|
47 |
+
return $this->getLevel();
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Override level setter to prevent setting the root logger's level to
|
52 |
+
* null. Root logger must always have a level.
|
53 |
+
*
|
54 |
+
* @param LoggerLevel $level
|
55 |
+
*/
|
56 |
+
public function setLevel(LoggerLevel $level = null) {
|
57 |
+
if (isset($level)) {
|
58 |
+
parent::setLevel($level);
|
59 |
+
} else {
|
60 |
+
trigger_error("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Override parent setter. Root logger cannot have a parent.
|
66 |
+
* @param Logger $parent
|
67 |
+
*/
|
68 |
+
public function setParent(Logger $parent) {
|
69 |
+
trigger_error("log4php: LoggerRoot cannot have a parent.", E_USER_WARNING);
|
70 |
+
}
|
71 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/LoggerThrowableInformation.php
RENAMED
@@ -32,16 +32,13 @@ class LoggerThrowableInformation {
|
|
32 |
/** @var array Array of throwable messages */
|
33 |
private $throwableArray;
|
34 |
|
35 |
-
/** @var Logger reference */
|
36 |
-
private $logger;
|
37 |
-
|
38 |
/**
|
39 |
* Create a new instance
|
40 |
*
|
41 |
* @param $throwable - a throwable as a exception
|
42 |
* @param $logger - Logger reference
|
43 |
*/
|
44 |
-
public function __construct(Exception $throwable)
|
45 |
$this->throwable = $throwable;
|
46 |
}
|
47 |
|
@@ -61,16 +58,11 @@ class LoggerThrowableInformation {
|
|
61 |
*/
|
62 |
public function getStringRepresentation() {
|
63 |
if (!is_array($this->throwableArray)) {
|
64 |
-
$renderer =
|
65 |
|
66 |
-
// TODO: why this?
|
67 |
-
if ($renderer instanceof LoggerRendererDefault) {
|
68 |
-
$renderer = new LoggerRendererException();
|
69 |
-
}
|
70 |
$this->throwableArray = explode("\n", $renderer->render($this->throwable));
|
71 |
}
|
72 |
|
73 |
return $this->throwableArray;
|
74 |
}
|
75 |
}
|
76 |
-
?>
|
32 |
/** @var array Array of throwable messages */
|
33 |
private $throwableArray;
|
34 |
|
|
|
|
|
|
|
35 |
/**
|
36 |
* Create a new instance
|
37 |
*
|
38 |
* @param $throwable - a throwable as a exception
|
39 |
* @param $logger - Logger reference
|
40 |
*/
|
41 |
+
public function __construct(Exception $throwable) {
|
42 |
$this->throwable = $throwable;
|
43 |
}
|
44 |
|
58 |
*/
|
59 |
public function getStringRepresentation() {
|
60 |
if (!is_array($this->throwableArray)) {
|
61 |
+
$renderer = new LoggerRendererException();
|
62 |
|
|
|
|
|
|
|
|
|
63 |
$this->throwableArray = explode("\n", $renderer->render($this->throwable));
|
64 |
}
|
65 |
|
66 |
return $this->throwableArray;
|
67 |
}
|
68 |
}
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderConsole.php
RENAMED
@@ -1,105 +1,103 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
* - target
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
*
|
51 |
-
*
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
$this->
|
71 |
-
}
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
$
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
}
|
105 |
-
|
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 |
+
|
19 |
+
/**
|
20 |
+
* LoggerAppenderConsole appends log events either to the standard output
|
21 |
+
* stream (php://stdout) or the standard error stream (php://stderr).
|
22 |
+
*
|
23 |
+
* **Note**: Use this Appender with command-line php scripts. On web scripts
|
24 |
+
* this appender has no effects.
|
25 |
+
*
|
26 |
+
* This appender uses a layout.
|
27 |
+
*
|
28 |
+
* ## Configurable parameters: ##
|
29 |
+
*
|
30 |
+
* - **target** - the target stream: "stdout" or "stderr"
|
31 |
+
*
|
32 |
+
* @version $Revision: 1343601 $
|
33 |
+
* @package log4php
|
34 |
+
* @subpackage appenders
|
35 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
36 |
+
* @link http://logging.apache.org/log4php/docs/appenders/console.html Appender documentation
|
37 |
+
*/
|
38 |
+
class LoggerAppenderConsole extends LoggerAppender {
|
39 |
+
|
40 |
+
/** The standard otuput stream. */
|
41 |
+
const STDOUT = 'php://stdout';
|
42 |
+
|
43 |
+
/** The standard error stream.*/
|
44 |
+
const STDERR = 'php://stderr';
|
45 |
+
|
46 |
+
/** The 'target' parameter. */
|
47 |
+
protected $target = self::STDOUT;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Stream resource for the target stream.
|
51 |
+
* @var resource
|
52 |
+
*/
|
53 |
+
protected $fp = null;
|
54 |
+
|
55 |
+
public function activateOptions() {
|
56 |
+
$this->fp = fopen($this->target, 'w');
|
57 |
+
if(is_resource($this->fp) && $this->layout !== null) {
|
58 |
+
fwrite($this->fp, $this->layout->getHeader());
|
59 |
+
}
|
60 |
+
$this->closed = (bool)is_resource($this->fp) === false;
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
public function close() {
|
65 |
+
if($this->closed != true) {
|
66 |
+
if (is_resource($this->fp) && $this->layout !== null) {
|
67 |
+
fwrite($this->fp, $this->layout->getFooter());
|
68 |
+
fclose($this->fp);
|
69 |
+
}
|
70 |
+
$this->closed = true;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
public function append(LoggerLoggingEvent $event) {
|
75 |
+
if (is_resource($this->fp) && $this->layout !== null) {
|
76 |
+
fwrite($this->fp, $this->layout->format($event));
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Sets the 'target' parameter.
|
82 |
+
* @param string $target
|
83 |
+
*/
|
84 |
+
public function setTarget($target) {
|
85 |
+
$value = trim($target);
|
86 |
+
if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') {
|
87 |
+
$this->target = self::STDOUT;
|
88 |
+
} elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') {
|
89 |
+
$this->target = self::STDERR;
|
90 |
+
} else {
|
91 |
+
$target = var_export($target);
|
92 |
+
$this->warn("Invalid value given for 'target' property: [$target]. Property not set.");
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Returns the value of the 'target' parameter.
|
98 |
+
* @return string
|
99 |
+
*/
|
100 |
+
public function getTarget() {
|
101 |
+
return $this->target;
|
102 |
+
}
|
103 |
+
}
|
|
|
|
lib/Log4php/appenders/LoggerAppenderDailyFile.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
19 |
+
/**
|
20 |
+
* An Appender that automatically creates a new logfile each day.
|
21 |
+
*
|
22 |
+
* The file is rolled over once a day. That means, for each day a new file
|
23 |
+
* is created. A formatted version of the date pattern is used as to create
|
24 |
+
* the file name using the {@link PHP_MANUAL#sprintf} function.
|
25 |
+
*
|
26 |
+
* This appender uses a layout.
|
27 |
+
*
|
28 |
+
* ##Configurable parameters:##
|
29 |
+
*
|
30 |
+
* - **datePattern** - Format for the date in the file path, follows formatting
|
31 |
+
* rules used by the PHP date() function. Default value: "Ymd".
|
32 |
+
* - **file** - Path to the target file. Should contain a %s which gets
|
33 |
+
* substituted by the date.
|
34 |
+
* - **append** - If set to true, the appender will append to the file,
|
35 |
+
* otherwise the file contents will be overwritten. Defaults to true.
|
36 |
+
*
|
37 |
+
* @version $Revision: 1382274 $
|
38 |
+
* @package log4php
|
39 |
+
* @subpackage appenders
|
40 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
41 |
+
* @link http://logging.apache.org/log4php/docs/appenders/daily-file.html Appender documentation
|
42 |
+
*/
|
43 |
+
class LoggerAppenderDailyFile extends LoggerAppenderFile {
|
44 |
+
|
45 |
+
/**
|
46 |
+
* The 'datePattern' parameter.
|
47 |
+
* Determines how date will be formatted in file name.
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
protected $datePattern = "Ymd";
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Current date which was used when opening a file.
|
54 |
+
* Used to determine if a rollover is needed when the date changes.
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
protected $currentDate;
|
58 |
+
|
59 |
+
/** Additional validation for the date pattern. */
|
60 |
+
public function activateOptions() {
|
61 |
+
parent::activateOptions();
|
62 |
+
|
63 |
+
if (empty($this->datePattern)) {
|
64 |
+
$this->warn("Required parameter 'datePattern' not set. Closing appender.");
|
65 |
+
$this->closed = true;
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Appends a logging event.
|
72 |
+
*
|
73 |
+
* If the target file changes because of passage of time (e.g. at midnight)
|
74 |
+
* the current file is closed. A new file, with the new date, will be
|
75 |
+
* opened by the write() method.
|
76 |
+
*/
|
77 |
+
public function append(LoggerLoggingEvent $event) {
|
78 |
+
$eventDate = $this->getDate($event->getTimestamp());
|
79 |
+
|
80 |
+
// Initial setting of current date
|
81 |
+
if (!isset($this->currentDate)) {
|
82 |
+
$this->currentDate = $eventDate;
|
83 |
+
}
|
84 |
+
|
85 |
+
// Check if rollover is needed
|
86 |
+
else if ($this->currentDate !== $eventDate) {
|
87 |
+
$this->currentDate = $eventDate;
|
88 |
+
|
89 |
+
// Close the file if it's open.
|
90 |
+
// Note: $this->close() is not called here because it would set
|
91 |
+
// $this->closed to true and the appender would not recieve
|
92 |
+
// any more logging requests
|
93 |
+
if (is_resource($this->fp)) {
|
94 |
+
$this->write($this->layout->getFooter());
|
95 |
+
fclose($this->fp);
|
96 |
+
}
|
97 |
+
$this->fp = null;
|
98 |
+
}
|
99 |
+
|
100 |
+
parent::append($event);
|
101 |
+
}
|
102 |
+
|
103 |
+
/** Renders the date using the configured <var>datePattern<var>. */
|
104 |
+
protected function getDate($timestamp = null) {
|
105 |
+
return date($this->datePattern, $timestamp);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Determines target file. Replaces %s in file path with a date.
|
110 |
+
*/
|
111 |
+
protected function getTargetFile() {
|
112 |
+
return str_replace('%s', $this->currentDate, $this->file);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Sets the 'datePattern' parameter.
|
117 |
+
* @param string $datePattern
|
118 |
+
*/
|
119 |
+
public function setDatePattern($datePattern) {
|
120 |
+
$this->setString('datePattern', $datePattern);
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Returns the 'datePattern' parameter.
|
125 |
+
* @return string
|
126 |
+
*/
|
127 |
+
public function getDatePattern() {
|
128 |
+
return $this->datePattern;
|
129 |
+
}
|
130 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderEcho.php
RENAMED
@@ -1,85 +1,88 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
$
|
67 |
-
}
|
68 |
-
$text
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
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 |
+
|
19 |
+
/**
|
20 |
+
* LoggerAppenderEcho uses the PHP echo() function to output events.
|
21 |
+
*
|
22 |
+
* This appender uses a layout.
|
23 |
+
*
|
24 |
+
* ## Configurable parameters: ##
|
25 |
+
*
|
26 |
+
* - **htmlLineBreaks** - If set to true, a <br /> element will be inserted
|
27 |
+
* before each line break in the logged message. Default is false.
|
28 |
+
*
|
29 |
+
* @version $Revision: 1337820 $
|
30 |
+
* @package log4php
|
31 |
+
* @subpackage appenders
|
32 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
33 |
+
* @link http://logging.apache.org/log4php/docs/appenders/echo.html Appender documentation
|
34 |
+
*/
|
35 |
+
class LoggerAppenderEcho extends LoggerAppender {
|
36 |
+
/**
|
37 |
+
* Used to mark first append. Set to false after first append.
|
38 |
+
* @var boolean
|
39 |
+
*/
|
40 |
+
protected $firstAppend = true;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* If set to true, a <br /> element will be inserted before each line
|
44 |
+
* break in the logged message. Default value is false. @var boolean
|
45 |
+
*/
|
46 |
+
protected $htmlLineBreaks = false;
|
47 |
+
|
48 |
+
public function close() {
|
49 |
+
if($this->closed != true) {
|
50 |
+
if(!$this->firstAppend) {
|
51 |
+
echo $this->layout->getFooter();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
$this->closed = true;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function append(LoggerLoggingEvent $event) {
|
58 |
+
if($this->layout !== null) {
|
59 |
+
if($this->firstAppend) {
|
60 |
+
echo $this->layout->getHeader();
|
61 |
+
$this->firstAppend = false;
|
62 |
+
}
|
63 |
+
$text = $this->layout->format($event);
|
64 |
+
|
65 |
+
if ($this->htmlLineBreaks) {
|
66 |
+
$text = nl2br($text);
|
67 |
+
}
|
68 |
+
echo $text;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Sets the 'htmlLineBreaks' parameter.
|
74 |
+
* @param boolean $value
|
75 |
+
*/
|
76 |
+
public function setHtmlLineBreaks($value) {
|
77 |
+
$this->setBoolean('htmlLineBreaks', $value);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Returns the 'htmlLineBreaks' parameter.
|
82 |
+
* @returns boolean
|
83 |
+
*/
|
84 |
+
public function getHtmlLineBreaks() {
|
85 |
+
return $this->htmlLineBreaks;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
lib/Log4php/appenders/LoggerAppenderFile.php
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
19 |
+
/**
|
20 |
+
* LoggerAppenderFile appends log events to a file.
|
21 |
+
*
|
22 |
+
* This appender uses a layout.
|
23 |
+
*
|
24 |
+
* ## Configurable parameters: ##
|
25 |
+
*
|
26 |
+
* - **file** - Path to the target file. Relative paths are resolved based on
|
27 |
+
* the working directory.
|
28 |
+
* - **append** - If set to true, the appender will append to the file,
|
29 |
+
* otherwise the file contents will be overwritten.
|
30 |
+
*
|
31 |
+
* @version $Revision: 1382274 $
|
32 |
+
* @package log4php
|
33 |
+
* @subpackage appenders
|
34 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
35 |
+
* @link http://logging.apache.org/log4php/docs/appenders/file.html Appender documentation
|
36 |
+
*/
|
37 |
+
class LoggerAppenderFile extends LoggerAppender {
|
38 |
+
|
39 |
+
/**
|
40 |
+
* If set to true, the file is locked before appending. This allows
|
41 |
+
* concurrent access. However, appending without locking is faster so
|
42 |
+
* it should be used where appropriate.
|
43 |
+
*
|
44 |
+
* TODO: make this a configurable parameter
|
45 |
+
*
|
46 |
+
* @var boolean
|
47 |
+
*/
|
48 |
+
protected $locking = true;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* If set to true, appends to file. Otherwise overwrites it.
|
52 |
+
* @var boolean
|
53 |
+
*/
|
54 |
+
protected $append = true;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Path to the target file.
|
58 |
+
* @var string
|
59 |
+
*/
|
60 |
+
protected $file;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* The file resource.
|
64 |
+
* @var resource
|
65 |
+
*/
|
66 |
+
protected $fp;
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Helper function which can be easily overriden by daily file appender.
|
70 |
+
*/
|
71 |
+
protected function getTargetFile() {
|
72 |
+
return $this->file;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Acquires the target file resource, creates the destination folder if
|
77 |
+
* necessary. Writes layout header to file.
|
78 |
+
*
|
79 |
+
* @return boolean FALSE if opening failed
|
80 |
+
*/
|
81 |
+
protected function openFile() {
|
82 |
+
$file = $this->getTargetFile();
|
83 |
+
|
84 |
+
// Create the target folder if needed
|
85 |
+
if(!is_file($file)) {
|
86 |
+
$dir = dirname($file);
|
87 |
+
|
88 |
+
if(!is_dir($dir)) {
|
89 |
+
$success = mkdir($dir, 0777, true);
|
90 |
+
if ($success === false) {
|
91 |
+
$this->warn("Failed creating target directory [$dir]. Closing appender.");
|
92 |
+
$this->closed = true;
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
$mode = $this->append ? 'a' : 'w';
|
99 |
+
$this->fp = fopen($file, $mode);
|
100 |
+
if ($this->fp === false) {
|
101 |
+
$this->warn("Failed opening target file. Closing appender.");
|
102 |
+
$this->fp = null;
|
103 |
+
$this->closed = true;
|
104 |
+
return false;
|
105 |
+
}
|
106 |
+
|
107 |
+
// Required when appending with concurrent access
|
108 |
+
if($this->append) {
|
109 |
+
fseek($this->fp, 0, SEEK_END);
|
110 |
+
}
|
111 |
+
|
112 |
+
// Write the header
|
113 |
+
$this->write($this->layout->getHeader());
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Writes a string to the target file. Opens file if not already open.
|
118 |
+
* @param string $string Data to write.
|
119 |
+
*/
|
120 |
+
protected function write($string) {
|
121 |
+
// Lazy file open
|
122 |
+
if(!isset($this->fp)) {
|
123 |
+
if ($this->openFile() === false) {
|
124 |
+
return; // Do not write if file open failed.
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($this->locking) {
|
129 |
+
$this->writeWithLocking($string);
|
130 |
+
} else {
|
131 |
+
$this->writeWithoutLocking($string);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
protected function writeWithLocking($string) {
|
136 |
+
if(flock($this->fp, LOCK_EX)) {
|
137 |
+
if(fwrite($this->fp, $string) === false) {
|
138 |
+
$this->warn("Failed writing to file. Closing appender.");
|
139 |
+
$this->closed = true;
|
140 |
+
}
|
141 |
+
flock($this->fp, LOCK_UN);
|
142 |
+
} else {
|
143 |
+
$this->warn("Failed locking file for writing. Closing appender.");
|
144 |
+
$this->closed = true;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
protected function writeWithoutLocking($string) {
|
149 |
+
if(fwrite($this->fp, $string) === false) {
|
150 |
+
$this->warn("Failed writing to file. Closing appender.");
|
151 |
+
$this->closed = true;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
public function activateOptions() {
|
156 |
+
if (empty($this->file)) {
|
157 |
+
$this->warn("Required parameter 'file' not set. Closing appender.");
|
158 |
+
$this->closed = true;
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
public function close() {
|
164 |
+
if (is_resource($this->fp)) {
|
165 |
+
$this->write($this->layout->getFooter());
|
166 |
+
fclose($this->fp);
|
167 |
+
}
|
168 |
+
$this->fp = null;
|
169 |
+
$this->closed = true;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function append(LoggerLoggingEvent $event) {
|
173 |
+
$this->write($this->layout->format($event));
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Sets the 'file' parameter.
|
178 |
+
* @param string $file
|
179 |
+
*/
|
180 |
+
public function setFile($file) {
|
181 |
+
$this->setString('file', $file);
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Returns the 'file' parameter.
|
186 |
+
* @return string
|
187 |
+
*/
|
188 |
+
public function getFile() {
|
189 |
+
return $this->file;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Returns the 'append' parameter.
|
194 |
+
* @return boolean
|
195 |
+
*/
|
196 |
+
public function getAppend() {
|
197 |
+
return $this->append;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Sets the 'append' parameter.
|
202 |
+
* @param boolean $append
|
203 |
+
*/
|
204 |
+
public function setAppend($append) {
|
205 |
+
$this->setBoolean('append', $append);
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Sets the 'file' parmeter. Left for legacy reasons.
|
210 |
+
* @param string $fileName
|
211 |
+
* @deprecated Use setFile() instead.
|
212 |
+
*/
|
213 |
+
public function setFileName($fileName) {
|
214 |
+
$this->setFile($fileName);
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Returns the 'file' parmeter. Left for legacy reasons.
|
219 |
+
* @return string
|
220 |
+
* @deprecated Use getFile() instead.
|
221 |
+
*/
|
222 |
+
public function getFileName() {
|
223 |
+
return $this->getFile();
|
224 |
+
}
|
225 |
+
}
|
lib/Log4php/appenders/LoggerAppenderFirePHP.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
19 |
+
/**
|
20 |
+
* Logs messages as HTTP headers using the FirePHP Insight API.
|
21 |
+
*
|
22 |
+
* This appender requires the FirePHP server library version 1.0 or later.
|
23 |
+
*
|
24 |
+
* ## Configurable parameters: ##
|
25 |
+
*
|
26 |
+
* - **target** - (string) The target to which messages will be sent. Possible options are
|
27 |
+
* 'page' (default), 'request', 'package' and 'controller'. For more details,
|
28 |
+
* see FirePHP documentation.
|
29 |
+
*
|
30 |
+
* This class was originally contributed by Bruce Ingalls (Bruce.Ingalls-at-gmail-dot-com).
|
31 |
+
*
|
32 |
+
* @link https://github.com/firephp/firephp FirePHP homepage.
|
33 |
+
* @link http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Welcome FirePHP documentation.
|
34 |
+
* @link http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Configuration/Constants FirePHP constants documentation.
|
35 |
+
* @link http://logging.apache.org/log4php/docs/appenders/firephp.html Appender documentation
|
36 |
+
*
|
37 |
+
* @version $Revision: 1343684 $
|
38 |
+
* @package log4php
|
39 |
+
* @subpackage appenders
|
40 |
+
* @since 2.3
|
41 |
+
*/
|
42 |
+
class LoggerAppenderFirePHP extends LoggerAppender {
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Instance of the Insight console class.
|
46 |
+
* @var Insight_Plugin_Console
|
47 |
+
*/
|
48 |
+
protected $console;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* The target for log messages. Possible values are: 'page' (default),
|
52 |
+
* 'request', 'package' and 'contoller'.
|
53 |
+
*/
|
54 |
+
protected $target = 'page';
|
55 |
+
|
56 |
+
public function activateOptions() {
|
57 |
+
if (method_exists('FirePHP', 'to')) {
|
58 |
+
$this->console = FirePHP::to($this->target)->console();
|
59 |
+
$this->closed = false;
|
60 |
+
} else {
|
61 |
+
$this->warn('FirePHP is not installed correctly. Closing appender.');
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
public function append(LoggerLoggingEvent $event) {
|
66 |
+
$msg = $event->getMessage();
|
67 |
+
|
68 |
+
// Skip formatting for objects and arrays which are handled by FirePHP.
|
69 |
+
if (!is_array($msg) && !is_object($msg)) {
|
70 |
+
$msg = $this->getLayout()->format($event);
|
71 |
+
}
|
72 |
+
|
73 |
+
switch ($event->getLevel()->toInt()) {
|
74 |
+
case LoggerLevel::TRACE:
|
75 |
+
case LoggerLevel::DEBUG:
|
76 |
+
$this->console->log($msg);
|
77 |
+
break;
|
78 |
+
case LoggerLevel::INFO:
|
79 |
+
$this->console->info($msg);
|
80 |
+
break;
|
81 |
+
case LoggerLevel::WARN:
|
82 |
+
$this->console->warn($msg);
|
83 |
+
break;
|
84 |
+
case LoggerLevel::ERROR:
|
85 |
+
case LoggerLevel::FATAL:
|
86 |
+
$this->console->error($msg);
|
87 |
+
break;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
/** Returns the target. */
|
92 |
+
public function getTarget() {
|
93 |
+
return $this->target;
|
94 |
+
}
|
95 |
+
|
96 |
+
/** Sets the target. */
|
97 |
+
public function setTarget($target) {
|
98 |
+
$this->setString('target', $target);
|
99 |
+
}
|
100 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderMail.php
RENAMED
@@ -1,113 +1,136 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
* -
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
40 |
-
*
|
41 |
-
*
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
/**
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
protected $
|
62 |
-
|
63 |
-
/**
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
public function
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
19 |
+
/**
|
20 |
+
* LoggerAppenderMail appends log events via email.
|
21 |
+
*
|
22 |
+
* This appender does not send individual emails for each logging requests but
|
23 |
+
* will collect them in a buffer and send them all in a single email once the
|
24 |
+
* appender is closed (i.e. when the script exists). Because of this, it may
|
25 |
+
* not appropriate for long running scripts, in which case
|
26 |
+
* LoggerAppenderMailEvent might be a better choice.
|
27 |
+
*
|
28 |
+
* This appender uses a layout.
|
29 |
+
*
|
30 |
+
* ## Configurable parameters: ##
|
31 |
+
*
|
32 |
+
* - **to** - Email address(es) to which the log will be sent. Multiple email
|
33 |
+
* addresses may be specified by separating them with a comma.
|
34 |
+
* - **from** - Email address which will be used in the From field.
|
35 |
+
* - **subject** - Subject of the email message.
|
36 |
+
*
|
37 |
+
* @version $Revision: 1337820 $
|
38 |
+
* @package log4php
|
39 |
+
* @subpackage appenders
|
40 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
41 |
+
* @link http://logging.apache.org/log4php/docs/appenders/mail.html Appender documentation
|
42 |
+
*/
|
43 |
+
class LoggerAppenderMail extends LoggerAppender {
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Email address to put in From field of the email.
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $from = null;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The subject of the email.
|
53 |
+
* @var string
|
54 |
+
*/
|
55 |
+
protected $subject = 'Log4php Report';
|
56 |
+
|
57 |
+
/**
|
58 |
+
* One or more comma separated email addresses to which to send the email.
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
protected $to = null;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Indiciates whether this appender should run in dry mode.
|
65 |
+
* @deprecated
|
66 |
+
* @var boolean
|
67 |
+
*/
|
68 |
+
protected $dry = false;
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Buffer which holds the email contents before it is sent.
|
72 |
+
* @var string
|
73 |
+
*/
|
74 |
+
protected $body = '';
|
75 |
+
|
76 |
+
public function append(LoggerLoggingEvent $event) {
|
77 |
+
if($this->layout !== null) {
|
78 |
+
$this->body .= $this->layout->format($event);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
public function close() {
|
83 |
+
if($this->closed != true) {
|
84 |
+
$from = $this->from;
|
85 |
+
$to = $this->to;
|
86 |
+
|
87 |
+
if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) {
|
88 |
+
$subject = $this->subject;
|
89 |
+
if(!$this->dry) {
|
90 |
+
mail(
|
91 |
+
$to, $subject,
|
92 |
+
$this->layout->getHeader() . $this->body . $this->layout->getFooter(),
|
93 |
+
"From: {$from}\r\n");
|
94 |
+
} else {
|
95 |
+
echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
$this->closed = true;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/** Sets the 'subject' parameter. */
|
103 |
+
public function setSubject($subject) {
|
104 |
+
$this->setString('subject', $subject);
|
105 |
+
}
|
106 |
+
|
107 |
+
/** Returns the 'subject' parameter. */
|
108 |
+
public function getSubject() {
|
109 |
+
return $this->subject;
|
110 |
+
}
|
111 |
+
|
112 |
+
/** Sets the 'to' parameter. */
|
113 |
+
public function setTo($to) {
|
114 |
+
$this->setString('to', $to);
|
115 |
+
}
|
116 |
+
|
117 |
+
/** Returns the 'to' parameter. */
|
118 |
+
public function getTo() {
|
119 |
+
return $this->to;
|
120 |
+
}
|
121 |
+
|
122 |
+
/** Sets the 'from' parameter. */
|
123 |
+
public function setFrom($from) {
|
124 |
+
$this->setString('from', $from);
|
125 |
+
}
|
126 |
+
|
127 |
+
/** Returns the 'from' parameter. */
|
128 |
+
public function getFrom() {
|
129 |
+
return $this->from;
|
130 |
+
}
|
131 |
+
|
132 |
+
/** Enables or disables dry mode. */
|
133 |
+
public function setDry($dry) {
|
134 |
+
$this->setBoolean('dry', $dry);
|
135 |
+
}
|
136 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderMailEvent.php
RENAMED
@@ -1,151 +1,180 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
* -
|
30 |
-
*
|
31 |
-
* -
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
40 |
-
*
|
41 |
-
*
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
* @
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
$this->
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
$this->
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
$
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
19 |
+
/**
|
20 |
+
* LoggerAppenderMailEvent appends individual log events via email.
|
21 |
+
*
|
22 |
+
* This appender is similar to LoggerAppenderMail, except that it sends each
|
23 |
+
* each log event in an individual email message at the time when it occurs.
|
24 |
+
*
|
25 |
+
* This appender uses a layout.
|
26 |
+
*
|
27 |
+
* ## Configurable parameters: ##
|
28 |
+
*
|
29 |
+
* - **to** - Email address(es) to which the log will be sent. Multiple email
|
30 |
+
* addresses may be specified by separating them with a comma.
|
31 |
+
* - **from** - Email address which will be used in the From field.
|
32 |
+
* - **subject** - Subject of the email message.
|
33 |
+
* - **smtpHost** - Used to override the SMTP server. Only works on Windows.
|
34 |
+
* - **port** - Used to override the default SMTP server port. Only works on
|
35 |
+
* Windows.
|
36 |
+
*
|
37 |
+
* @version $Revision: 1343601 $
|
38 |
+
* @package log4php
|
39 |
+
* @subpackage appenders
|
40 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
41 |
+
* @link http://logging.apache.org/log4php/docs/appenders/mail-event.html Appender documentation
|
42 |
+
*/
|
43 |
+
class LoggerAppenderMailEvent extends LoggerAppender {
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Email address to put in From field of the email.
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $from;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Mail server port (widnows only).
|
53 |
+
* @var integer
|
54 |
+
*/
|
55 |
+
protected $port = 25;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Mail server hostname (windows only).
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
protected $smtpHost;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* The subject of the email.
|
65 |
+
* @var string
|
66 |
+
*/
|
67 |
+
protected $subject = 'Log4php Report';
|
68 |
+
|
69 |
+
/**
|
70 |
+
* One or more comma separated email addresses to which to send the email.
|
71 |
+
* @var string
|
72 |
+
*/
|
73 |
+
protected $to = null;
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Indiciates whether this appender should run in dry mode.
|
77 |
+
* @deprecated
|
78 |
+
* @var boolean
|
79 |
+
*/
|
80 |
+
protected $dry = false;
|
81 |
+
|
82 |
+
public function activateOptions() {
|
83 |
+
if (empty($this->to)) {
|
84 |
+
$this->warn("Required parameter 'to' not set. Closing appender.");
|
85 |
+
$this->close = true;
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
$sendmail_from = ini_get('sendmail_from');
|
90 |
+
if (empty($this->from) and empty($sendmail_from)) {
|
91 |
+
$this->warn("Required parameter 'from' not set. Closing appender.");
|
92 |
+
$this->close = true;
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
$this->closed = false;
|
97 |
+
}
|
98 |
+
|
99 |
+
public function append(LoggerLoggingEvent $event) {
|
100 |
+
$smtpHost = $this->smtpHost;
|
101 |
+
$prevSmtpHost = ini_get('SMTP');
|
102 |
+
if(!empty($smtpHost)) {
|
103 |
+
ini_set('SMTP', $smtpHost);
|
104 |
+
}
|
105 |
+
|
106 |
+
$smtpPort = $this->port;
|
107 |
+
$prevSmtpPort= ini_get('smtp_port');
|
108 |
+
if($smtpPort > 0 and $smtpPort < 65535) {
|
109 |
+
ini_set('smtp_port', $smtpPort);
|
110 |
+
}
|
111 |
+
|
112 |
+
// On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
|
113 |
+
|
114 |
+
$addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
|
115 |
+
|
116 |
+
if(!$this->dry) {
|
117 |
+
$result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
|
118 |
+
} else {
|
119 |
+
echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
|
120 |
+
}
|
121 |
+
|
122 |
+
ini_set('SMTP', $prevSmtpHost);
|
123 |
+
ini_set('smtp_port', $prevSmtpPort);
|
124 |
+
}
|
125 |
+
|
126 |
+
/** Sets the 'from' parameter. */
|
127 |
+
public function setFrom($from) {
|
128 |
+
$this->setString('from', $from);
|
129 |
+
}
|
130 |
+
|
131 |
+
/** Returns the 'from' parameter. */
|
132 |
+
public function getFrom() {
|
133 |
+
return $this->from;
|
134 |
+
}
|
135 |
+
|
136 |
+
/** Sets the 'port' parameter. */
|
137 |
+
public function setPort($port) {
|
138 |
+
$this->setPositiveInteger('port', $port);
|
139 |
+
}
|
140 |
+
|
141 |
+
/** Returns the 'port' parameter. */
|
142 |
+
public function getPort() {
|
143 |
+
return $this->port;
|
144 |
+
}
|
145 |
+
|
146 |
+
/** Sets the 'smtpHost' parameter. */
|
147 |
+
public function setSmtpHost($smtpHost) {
|
148 |
+
$this->setString('smtpHost', $smtpHost);
|
149 |
+
}
|
150 |
+
|
151 |
+
/** Returns the 'smtpHost' parameter. */
|
152 |
+
public function getSmtpHost() {
|
153 |
+
return $this->smtpHost;
|
154 |
+
}
|
155 |
+
|
156 |
+
/** Sets the 'subject' parameter. */
|
157 |
+
public function setSubject($subject) {
|
158 |
+
$this->setString('subject', $subject);
|
159 |
+
}
|
160 |
+
|
161 |
+
/** Returns the 'subject' parameter. */
|
162 |
+
public function getSubject() {
|
163 |
+
return $this->subject;
|
164 |
+
}
|
165 |
+
|
166 |
+
/** Sets the 'to' parameter. */
|
167 |
+
public function setTo($to) {
|
168 |
+
$this->setString('to', $to);
|
169 |
+
}
|
170 |
+
|
171 |
+
/** Returns the 'to' parameter. */
|
172 |
+
public function getTo() {
|
173 |
+
return $this->to;
|
174 |
+
}
|
175 |
+
|
176 |
+
/** Enables or disables dry mode. */
|
177 |
+
public function setDry($dry) {
|
178 |
+
$this->setBoolean('dry', $dry);
|
179 |
+
}
|
180 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderMemory.php
RENAMED
File without changes
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderMongoDB.php
RENAMED
@@ -1,314 +1,360 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
/** Default
|
50 |
-
const
|
51 |
-
|
52 |
-
/** Default value for {@link $
|
53 |
-
const
|
54 |
-
|
55 |
-
/** Default value for {@link $
|
56 |
-
const
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
/**
|
72 |
-
protected $
|
73 |
-
|
74 |
-
/**
|
75 |
-
protected $
|
76 |
-
|
77 |
-
/**
|
78 |
-
protected $
|
79 |
-
|
80 |
-
/**
|
81 |
-
protected $
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
protected $
|
107 |
-
|
108 |
-
public function __construct($name = '') {
|
109 |
-
parent::__construct($name);
|
110 |
-
$this->host = self::DEFAULT_MONGO_URL_PREFIX . self::DEFAULT_MONGO_HOST;
|
111 |
-
$this->port = self::DEFAULT_MONGO_PORT;
|
112 |
-
$this->databaseName = self::DEFAULT_DB_NAME;
|
113 |
-
$this->collectionName = self::DEFAULT_COLLECTION_NAME;
|
114 |
-
$this->timeout = self::DEFAULT_TIMEOUT_VALUE;
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
*
|
120 |
-
*
|
121 |
-
*
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
$
|
127 |
-
|
128 |
-
|
129 |
-
$authResult
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
$this->
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
*
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
$document['
|
185 |
-
}
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
*
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
$this->
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
public function
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
public function
|
271 |
-
$this->setString('
|
272 |
-
}
|
273 |
-
|
274 |
-
/**
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
/**
|
299 |
-
*
|
300 |
-
* @
|
301 |
-
*/
|
302 |
-
public function
|
303 |
-
|
304 |
-
}
|
305 |
-
|
306 |
-
/**
|
307 |
-
* Returns the
|
308 |
-
* @return
|
309 |
-
*/
|
310 |
-
public function
|
311 |
-
return $this->
|
312 |
-
}
|
313 |
-
|
314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
19 |
+
/**
|
20 |
+
* Appender for writing to MongoDB.
|
21 |
+
*
|
22 |
+
* This class was originally contributed by Vladimir Gorej.
|
23 |
+
*
|
24 |
+
* ## Configurable parameters: ##
|
25 |
+
*
|
26 |
+
* - **host** - Server on which mongodb instance is located.
|
27 |
+
* - **port** - Port on which the instance is bound.
|
28 |
+
* - **databaseName** - Name of the database to which to log.
|
29 |
+
* - **collectionName** - Name of the target collection within the given database.
|
30 |
+
* - **username** - Username used to connect to the database.
|
31 |
+
* - **password** - Password used to connect to the database.
|
32 |
+
* - **timeout** - For how long the driver should try to connect to the database (in milliseconds).
|
33 |
+
*
|
34 |
+
* @version $Revision: 1346363 $
|
35 |
+
* @package log4php
|
36 |
+
* @subpackage appenders
|
37 |
+
* @since 2.1
|
38 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
39 |
+
* @link http://logging.apache.org/log4php/docs/appenders/mongodb.html Appender documentation
|
40 |
+
* @link http://github.com/log4mongo/log4mongo-php Vladimir Gorej's original submission.
|
41 |
+
* @link http://www.mongodb.org/ MongoDB website.
|
42 |
+
*/
|
43 |
+
class LoggerAppenderMongoDB extends LoggerAppender {
|
44 |
+
|
45 |
+
// ******************************************
|
46 |
+
// ** Constants **
|
47 |
+
// ******************************************
|
48 |
+
|
49 |
+
/** Default prefix for the {@link $host}. */
|
50 |
+
const DEFAULT_MONGO_URL_PREFIX = 'mongodb://';
|
51 |
+
|
52 |
+
/** Default value for {@link $host}, without a prefix. */
|
53 |
+
const DEFAULT_MONGO_HOST = 'localhost';
|
54 |
+
|
55 |
+
/** Default value for {@link $port} */
|
56 |
+
const DEFAULT_MONGO_PORT = 27017;
|
57 |
+
|
58 |
+
/** Default value for {@link $databaseName} */
|
59 |
+
const DEFAULT_DB_NAME = 'log4php_mongodb';
|
60 |
+
|
61 |
+
/** Default value for {@link $collectionName} */
|
62 |
+
const DEFAULT_COLLECTION_NAME = 'logs';
|
63 |
+
|
64 |
+
/** Default value for {@link $timeout} */
|
65 |
+
const DEFAULT_TIMEOUT_VALUE = 3000;
|
66 |
+
|
67 |
+
// ******************************************
|
68 |
+
// ** Configurable parameters **
|
69 |
+
// ******************************************
|
70 |
+
|
71 |
+
/** Server on which mongodb instance is located. */
|
72 |
+
protected $host;
|
73 |
+
|
74 |
+
/** Port on which the instance is bound. */
|
75 |
+
protected $port;
|
76 |
+
|
77 |
+
/** Name of the database to which to log. */
|
78 |
+
protected $databaseName;
|
79 |
+
|
80 |
+
/** Name of the collection within the given database. */
|
81 |
+
protected $collectionName;
|
82 |
+
|
83 |
+
/** Username used to connect to the database. */
|
84 |
+
protected $userName;
|
85 |
+
|
86 |
+
/** Password used to connect to the database. */
|
87 |
+
protected $password;
|
88 |
+
|
89 |
+
/** Timeout value used when connecting to the database (in milliseconds). */
|
90 |
+
protected $timeout;
|
91 |
+
|
92 |
+
// ******************************************
|
93 |
+
// ** Member variables **
|
94 |
+
// ******************************************
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Connection to the MongoDB instance.
|
98 |
+
* @var Mongo
|
99 |
+
*/
|
100 |
+
protected $connection;
|
101 |
+
|
102 |
+
/**
|
103 |
+
* The collection to which log is written.
|
104 |
+
* @var MongoCollection
|
105 |
+
*/
|
106 |
+
protected $collection;
|
107 |
+
|
108 |
+
public function __construct($name = '') {
|
109 |
+
parent::__construct($name);
|
110 |
+
$this->host = self::DEFAULT_MONGO_URL_PREFIX . self::DEFAULT_MONGO_HOST;
|
111 |
+
$this->port = self::DEFAULT_MONGO_PORT;
|
112 |
+
$this->databaseName = self::DEFAULT_DB_NAME;
|
113 |
+
$this->collectionName = self::DEFAULT_COLLECTION_NAME;
|
114 |
+
$this->timeout = self::DEFAULT_TIMEOUT_VALUE;
|
115 |
+
$this->requiresLayout = false;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Setup db connection.
|
120 |
+
* Based on defined options, this method connects to the database and
|
121 |
+
* creates a {@link $collection}.
|
122 |
+
*/
|
123 |
+
public function activateOptions() {
|
124 |
+
try {
|
125 |
+
$this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array('timeout' => $this->timeout));
|
126 |
+
$db = $this->connection->selectDB($this->databaseName);
|
127 |
+
if ($this->userName !== null && $this->password !== null) {
|
128 |
+
$authResult = $db->authenticate($this->userName, $this->password);
|
129 |
+
if ($authResult['ok'] == floatval(0)) {
|
130 |
+
throw new Exception($authResult['errmsg'], $authResult['ok']);
|
131 |
+
}
|
132 |
+
}
|
133 |
+
$this->collection = $db->selectCollection($this->collectionName);
|
134 |
+
} catch (MongoConnectionException $ex) {
|
135 |
+
$this->closed = true;
|
136 |
+
$this->warn(sprintf('Failed to connect to mongo deamon: %s', $ex->getMessage()));
|
137 |
+
} catch (InvalidArgumentException $ex) {
|
138 |
+
$this->closed = true;
|
139 |
+
$this->warn(sprintf('Error while selecting mongo database: %s', $ex->getMessage()));
|
140 |
+
} catch (Exception $ex) {
|
141 |
+
$this->closed = true;
|
142 |
+
$this->warn('Invalid credentials for mongo database authentication');
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Appends a new event to the mongo database.
|
148 |
+
*
|
149 |
+
* @param LoggerLoggingEvent $event
|
150 |
+
*/
|
151 |
+
public function append(LoggerLoggingEvent $event) {
|
152 |
+
try {
|
153 |
+
if ($this->collection != null) {
|
154 |
+
$this->collection->insert($this->format($event));
|
155 |
+
}
|
156 |
+
} catch (MongoCursorException $ex) {
|
157 |
+
$this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage()));
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Converts the logging event into an array which can be logged to mongodb.
|
163 |
+
*
|
164 |
+
* @param LoggerLoggingEvent $event
|
165 |
+
* @return array The array representation of the logging event.
|
166 |
+
*/
|
167 |
+
protected function format(LoggerLoggingEvent $event) {
|
168 |
+
$timestampSec = (int) $event->getTimestamp();
|
169 |
+
$timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);
|
170 |
+
|
171 |
+
$document = array(
|
172 |
+
'timestamp' => new MongoDate($timestampSec, $timestampUsec),
|
173 |
+
'level' => $event->getLevel()->toString(),
|
174 |
+
'thread' => (int) $event->getThreadName(),
|
175 |
+
'message' => $event->getMessage(),
|
176 |
+
'loggerName' => $event->getLoggerName()
|
177 |
+
);
|
178 |
+
|
179 |
+
$locationInfo = $event->getLocationInformation();
|
180 |
+
if ($locationInfo != null) {
|
181 |
+
$document['fileName'] = $locationInfo->getFileName();
|
182 |
+
$document['method'] = $locationInfo->getMethodName();
|
183 |
+
$document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int) $locationInfo->getLineNumber();
|
184 |
+
$document['className'] = $locationInfo->getClassName();
|
185 |
+
}
|
186 |
+
|
187 |
+
$throwableInfo = $event->getThrowableInformation();
|
188 |
+
if ($throwableInfo != null) {
|
189 |
+
$document['exception'] = $this->formatThrowable($throwableInfo->getThrowable());
|
190 |
+
}
|
191 |
+
|
192 |
+
return $document;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Converts an Exception into an array which can be logged to mongodb.
|
197 |
+
*
|
198 |
+
* Supports innner exceptions (PHP >= 5.3)
|
199 |
+
*
|
200 |
+
* @param Exception $ex
|
201 |
+
* @return array
|
202 |
+
*/
|
203 |
+
protected function formatThrowable(Exception $ex) {
|
204 |
+
$array = array(
|
205 |
+
'message' => $ex->getMessage(),
|
206 |
+
'code' => $ex->getCode(),
|
207 |
+
'stackTrace' => $ex->getTraceAsString(),
|
208 |
+
);
|
209 |
+
|
210 |
+
if (method_exists($ex, 'getPrevious') && $ex->getPrevious() !== null) {
|
211 |
+
$array['innerException'] = $this->formatThrowable($ex->getPrevious());
|
212 |
+
}
|
213 |
+
|
214 |
+
return $array;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Closes the connection to the logging database
|
219 |
+
*/
|
220 |
+
public function close() {
|
221 |
+
if($this->closed != true) {
|
222 |
+
$this->collection = null;
|
223 |
+
if ($this->connection !== null) {
|
224 |
+
$this->connection->close();
|
225 |
+
$this->connection = null;
|
226 |
+
}
|
227 |
+
$this->closed = true;
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Sets the value of {@link $host} parameter.
|
233 |
+
* @param string $host
|
234 |
+
*/
|
235 |
+
public function setHost($host) {
|
236 |
+
if (!preg_match('/^mongodb\:\/\//', $host)) {
|
237 |
+
$host = self::DEFAULT_MONGO_URL_PREFIX . $host;
|
238 |
+
}
|
239 |
+
$this->host = $host;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Returns the value of {@link $host} parameter.
|
244 |
+
* @return string
|
245 |
+
*/
|
246 |
+
public function getHost() {
|
247 |
+
return $this->host;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Sets the value of {@link $port} parameter.
|
252 |
+
* @param int $port
|
253 |
+
*/
|
254 |
+
public function setPort($port) {
|
255 |
+
$this->setPositiveInteger('port', $port);
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Returns the value of {@link $port} parameter.
|
260 |
+
* @return int
|
261 |
+
*/
|
262 |
+
public function getPort() {
|
263 |
+
return $this->port;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Sets the value of {@link $databaseName} parameter.
|
268 |
+
* @param string $databaseName
|
269 |
+
*/
|
270 |
+
public function setDatabaseName($databaseName) {
|
271 |
+
$this->setString('databaseName', $databaseName);
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Returns the value of {@link $databaseName} parameter.
|
276 |
+
* @return string
|
277 |
+
*/
|
278 |
+
public function getDatabaseName() {
|
279 |
+
return $this->databaseName;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Sets the value of {@link $collectionName} parameter.
|
284 |
+
* @param string $collectionName
|
285 |
+
*/
|
286 |
+
public function setCollectionName($collectionName) {
|
287 |
+
$this->setString('collectionName', $collectionName);
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Returns the value of {@link $collectionName} parameter.
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
public function getCollectionName() {
|
295 |
+
return $this->collectionName;
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Sets the value of {@link $userName} parameter.
|
300 |
+
* @param string $userName
|
301 |
+
*/
|
302 |
+
public function setUserName($userName) {
|
303 |
+
$this->setString('userName', $userName, true);
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Returns the value of {@link $userName} parameter.
|
308 |
+
* @return string
|
309 |
+
*/
|
310 |
+
public function getUserName() {
|
311 |
+
return $this->userName;
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Sets the value of {@link $password} parameter.
|
316 |
+
* @param string $password
|
317 |
+
*/
|
318 |
+
public function setPassword($password) {
|
319 |
+
$this->setString('password', $password, true);
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Returns the value of {@link $password} parameter.
|
324 |
+
* @return string
|
325 |
+
*/
|
326 |
+
public function getPassword() {
|
327 |
+
return $this->password;
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Sets the value of {@link $timeout} parameter.
|
332 |
+
* @param int $timeout
|
333 |
+
*/
|
334 |
+
public function setTimeout($timeout) {
|
335 |
+
$this->setPositiveInteger('timeout', $timeout);
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Returns the value of {@link $timeout} parameter.
|
340 |
+
* @return int
|
341 |
+
*/
|
342 |
+
public function getTimeout() {
|
343 |
+
return $this->timeout;
|
344 |
+
}
|
345 |
+
/**
|
346 |
+
* Returns the mongodb connection.
|
347 |
+
* @return Mongo
|
348 |
+
*/
|
349 |
+
public function getConnection() {
|
350 |
+
return $this->connection;
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Returns the active mongodb collection.
|
355 |
+
* @return MongoCollection
|
356 |
+
*/
|
357 |
+
public function getCollection() {
|
358 |
+
return $this->collection;
|
359 |
+
}
|
360 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderNull.php
RENAMED
@@ -1,51 +1,44 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
*
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
*
|
46 |
-
* @param LoggerLoggingEvent $event
|
47 |
-
*/
|
48 |
-
public function append(LoggerLoggingEvent $event) {
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
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 |
+
|
19 |
+
/**
|
20 |
+
* A NullAppender merely exists, it never outputs a message to any device.
|
21 |
+
*
|
22 |
+
* This appender has no configurable parameters.
|
23 |
+
*
|
24 |
+
* @version $Revision: 1343601 $
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage appenders
|
27 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
28 |
+
* @link http://logging.apache.org/log4php/docs/appenders/null.html Appender documentation
|
29 |
+
*/
|
30 |
+
class LoggerAppenderNull extends LoggerAppender {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* This appender does not require a layout.
|
34 |
+
*/
|
35 |
+
protected $requiresLayout = false;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Do nothing.
|
39 |
+
*
|
40 |
+
* @param LoggerLoggingEvent $event
|
41 |
+
*/
|
42 |
+
public function append(LoggerLoggingEvent $event) {
|
43 |
+
}
|
44 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Log4php/appenders/LoggerAppenderPDO.php
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
19 |
+
/**
|
20 |
+
* LoggerAppenderPDO appender logs to a database using the PHP's PDO extension.
|
21 |
+
*
|
22 |
+
* ## Configurable parameters: ##
|
23 |
+
*
|
24 |
+
* - dsn - The Data Source Name (DSN) used to connect to the database.
|
25 |
+
* - user - Username used to connect to the database.
|
26 |
+
* - password - Password used to connect to the database.
|
27 |
+
* - table - Name of the table to which log entries are be inserted.
|
28 |
+
* - insertSQL - Sets the insert statement for a logging event. Defaults
|
29 |
+
* to the correct one - change only if you are sure what you are doing.
|
30 |
+
* - insertPattern - The conversion pattern to use in conjuction with insert
|
31 |
+
* SQL. Must contain the same number of comma separated
|
32 |
+
* conversion patterns as there are question marks in the
|
33 |
+
* insertSQL.
|
34 |
+
*
|
35 |
+
* @version $Revision: 1374546 $
|
36 |
+
* @package log4php
|
37 |
+
* @subpackage appenders
|
38 |
+
* @since 2.0
|
39 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
40 |
+
* @link http://logging.apache.org/log4php/docs/appenders/pdo.html Appender documentation
|
41 |
+
*/
|
42 |
+
class LoggerAppenderPDO extends LoggerAppender {
|
43 |
+
|
44 |
+
// ******************************************
|
45 |
+
// *** Configurable parameters ***
|
46 |
+
// ******************************************
|
47 |
+
|
48 |
+
/**
|
49 |
+
* DSN string used to connect to the database.
|
50 |
+
* @see http://www.php.net/manual/en/pdo.construct.php
|
51 |
+
*/
|
52 |
+
protected $dsn;
|
53 |
+
|
54 |
+
/** Database user name. */
|
55 |
+
protected $user;
|
56 |
+
|
57 |
+
/** Database password. */
|
58 |
+
protected $password;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* The insert query.
|
62 |
+
*
|
63 |
+
* The __TABLE__ placeholder will be replaced by the table name from
|
64 |
+
* {@link $table}.
|
65 |
+
*
|
66 |
+
* The questionmarks are part of the prepared statement, and they must
|
67 |
+
* match the number of conversion specifiers in {@link insertPattern}.
|
68 |
+
*/
|
69 |
+
protected $insertSQL = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
70 |
+
|
71 |
+
/**
|
72 |
+
* A comma separated list of {@link LoggerPatternLayout} format strings
|
73 |
+
* which replace the "?" in {@link $insertSQL}.
|
74 |
+
*
|
75 |
+
* Must contain the same number of comma separated conversion patterns as
|
76 |
+
* there are question marks in {@link insertSQL}.
|
77 |
+
*
|
78 |
+
* @see LoggerPatternLayout For conversion patterns.
|
79 |
+
*/
|
80 |
+
protected $insertPattern = "%date{Y-m-d H:i:s},%logger,%level,%message,%pid,%file,%line";
|
81 |
+
|
82 |
+
/** Name of the table to which to append log events. */
|
83 |
+
protected $table = 'log4php_log';
|
84 |
+
|
85 |
+
/** The number of recconect attempts to make on failed append. */
|
86 |
+
protected $reconnectAttempts = 3;
|
87 |
+
|
88 |
+
|
89 |
+
// ******************************************
|
90 |
+
// *** Private memebers ***
|
91 |
+
// ******************************************
|
92 |
+
|
93 |
+
/**
|
94 |
+
* The PDO instance.
|
95 |
+
* @var PDO
|
96 |
+
*/
|
97 |
+
protected $db;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Prepared statement for the insert query.
|
101 |
+
* @var PDOStatement
|
102 |
+
*/
|
103 |
+
protected $preparedInsert;
|
104 |
+
|
105 |
+
/** This appender does not require a layout. */
|
106 |
+
protected $requiresLayout = false;
|
107 |
+
|
108 |
+
|
109 |
+
// ******************************************
|
110 |
+
// *** Appender methods ***
|
111 |
+
// ******************************************
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Acquires a database connection based on parameters.
|
115 |
+
* Parses the insert pattern to create a chain of converters which will be
|
116 |
+
* used in forming query parameters from logging events.
|
117 |
+
*/
|
118 |
+
public function activateOptions() {
|
119 |
+
try {
|
120 |
+
$this->establishConnection();
|
121 |
+
} catch (PDOException $e) {
|
122 |
+
$this->warn("Failed connecting to database. Closing appender. Error: " . $e->getMessage());
|
123 |
+
$this->close();
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
|
127 |
+
// Parse the insert patterns; pattern parts are comma delimited
|
128 |
+
$pieces = explode(',', $this->insertPattern);
|
129 |
+
$converterMap = LoggerLayoutPattern::getDefaultConverterMap();
|
130 |
+
foreach($pieces as $pattern) {
|
131 |
+
$parser = new LoggerPatternParser($pattern, $converterMap);
|
132 |
+
$this->converters[] = $parser->parse();
|
133 |
+
}
|
134 |
+
|
135 |
+
$this->closed = false;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Connects to the database, and prepares the insert query.
|
140 |
+
* @throws PDOException If connect or prepare fails.
|
141 |
+
*/
|
142 |
+
protected function establishConnection() {
|
143 |
+
// Acquire database connection
|
144 |
+
$this->db = new PDO($this->dsn, $this->user, $this->password);
|
145 |
+
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
146 |
+
|
147 |
+
// Prepare the insert statement
|
148 |
+
$insertSQL = str_replace('__TABLE__', $this->table, $this->insertSQL);
|
149 |
+
$this->preparedInsert = $this->db->prepare($insertSQL);
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Appends a new event to the database.
|
154 |
+
*
|
155 |
+
* If writing to database fails, it will retry by re-establishing the
|
156 |
+
* connection up to $reconnectAttempts times. If writing still fails,
|
157 |
+
* the appender will close.
|
158 |
+
*/
|
159 |
+
public function append(LoggerLoggingEvent $event) {
|
160 |
+
|
161 |
+
for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) {
|
162 |
+
try {
|
163 |
+
// Attempt to write to database
|
164 |
+
$this->preparedInsert->execute($this->format($event));
|
165 |
+
$this->preparedInsert->closeCursor();
|
166 |
+
break;
|
167 |
+
} catch (PDOException $e) {
|
168 |
+
$this->warn("Failed writing to database: ". $e->getMessage());
|
169 |
+
|
170 |
+
// Close the appender if it's the last attempt
|
171 |
+
if ($attempt > $this->reconnectAttempts) {
|
172 |
+
$this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
|
173 |
+
$this->close();
|
174 |
+
// Otherwise reconnect and try to write again
|
175 |
+
} else {
|
176 |
+
$this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).");
|
177 |
+
$this->establishConnection();
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Converts the logging event to a series of database parameters by using
|
185 |
+
* the converter chain which was set up on activation.
|
186 |
+
*/
|
187 |
+
protected function format(LoggerLoggingEvent $event) {
|
188 |
+
$params = array();
|
189 |
+
foreach($this->converters as $converter) {
|
190 |
+
$buffer = '';
|
191 |
+
while ($converter !== null) {
|
192 |
+
$converter->format($buffer, $event);
|
193 |
+
$converter = $converter->next;
|
194 |
+
}
|
195 |
+
$params[] = $buffer;
|
196 |
+
}
|
197 |
+
return $params;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Closes the connection to the logging database
|
202 |
+
*/
|
203 |
+
public function close() {
|
204 |
+
// Close the connection (if any)
|
205 |
+
$this->db = null;
|
206 |
+
|
207 |
+
// Close the appender
|
208 |
+
$this->closed = true;
|
209 |
+
}
|
210 |
+
|
211 |
+
// ******************************************
|
212 |
+
// *** Accessor methods ***
|
213 |
+
// ******************************************
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Returns the active database handle or null if not established.
|
217 |
+
* @return PDO
|
218 |
+
*/
|
219 |
+
public function getDatabaseHandle() {
|
220 |
+
return $this->db;
|
221 |
+
}
|
222 |
+
|
223 |
+
/** Sets the username. */
|
224 |
+
public function setUser($user) {
|
225 |
+
$this->setString('user', $user);
|
226 |
+
}
|
227 |
+
|
228 |
+
/** Returns the username. */
|
229 |
+
public function getUser($user) {
|
230 |
+
return $this->user;
|
231 |
+
}
|
232 |
+
|
233 |
+
/** Sets the password. */
|
234 |
+
public function setPassword($password) {
|
235 |
+
$this->setString('password', $password);
|
236 |
+
}
|
237 |
+
|
238 |
+
/** Returns the password. */
|
239 |
+
public function getPassword($password) {
|
240 |
+
return $this->password;
|
241 |
+
}
|
242 |
+
|
243 |
+
/** Sets the insert SQL. */
|
244 |
+
public function setInsertSQL($sql) {
|
245 |
+
$this->setString('insertSQL', $sql);
|
246 |
+
}
|
247 |
+
|
248 |
+
/** Returns the insert SQL. */
|
249 |
+
public function getInsertSQL($sql) {
|
250 |
+
return $this->insertSQL;
|
251 |
+
}
|
252 |
+
|
253 |
+
/** Sets the insert pattern. */
|
254 |
+
public function setInsertPattern($pattern) {
|
255 |
+
$this->setString('insertPattern', $pattern);
|
256 |
+
}
|
257 |
+
|
258 |
+
/** Returns the insert pattern. */
|
259 |
+
public function getInsertPattern($pattern) {
|
260 |
+
return $this->insertPattern;
|
261 |
+
}
|
262 |
+
|
263 |
+
/** Sets the table name. */
|
264 |
+
public function setTable($table) {
|
265 |
+
$this->setString('table', $table);
|
266 |
+
}
|
267 |
+
|
268 |
+
/** Returns the table name. */
|
269 |
+
public function getTable($table) {
|
270 |
+
return $this->table;
|
271 |
+
}
|
272 |
+
|
273 |
+
/** Sets the DSN string. */
|
274 |
+
public function setDSN($dsn) {
|
275 |
+
$this->setString('dsn', $dsn);
|
276 |
+
}
|
277 |
+
|
278 |
+
/** Returns the DSN string. */
|
279 |
+
public function getDSN($dsn) {
|
280 |
+
return $this->setString('dsn', $dsn);
|
281 |
+
}
|
282 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderPhp.php
RENAMED
@@ -1,56 +1,49 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
* - <b>level <
|
29 |
-
* - <b>
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
$
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
trigger_error($this->layout->format($event), E_USER_WARNING);
|
51 |
-
} else {
|
52 |
-
trigger_error($this->layout->format($event), E_USER_NOTICE);
|
53 |
-
}
|
54 |
-
}
|
55 |
-
}
|
56 |
-
}
|
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 |
+
|
19 |
+
/**
|
20 |
+
* LoggerAppenderPhp logs events by creating a PHP user-level message using
|
21 |
+
* the PHP's trigger_error()function.
|
22 |
+
*
|
23 |
+
* This appender has no configurable parameters.
|
24 |
+
*
|
25 |
+
* Levels are mapped as follows:
|
26 |
+
*
|
27 |
+
* - <b>level < WARN</b> mapped to E_USER_NOTICE
|
28 |
+
* - <b>WARN <= level < ERROR</b> mapped to E_USER_WARNING
|
29 |
+
* - <b>level >= ERROR</b> mapped to E_USER_ERROR
|
30 |
+
*
|
31 |
+
* @version $Revision: 1337820 $
|
32 |
+
* @package log4php
|
33 |
+
* @subpackage appenders
|
34 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
35 |
+
* @link http://logging.apache.org/log4php/docs/appenders/php.html Appender documentation
|
36 |
+
*/
|
37 |
+
class LoggerAppenderPhp extends LoggerAppender {
|
38 |
+
|
39 |
+
public function append(LoggerLoggingEvent $event) {
|
40 |
+
$level = $event->getLevel();
|
41 |
+
if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
|
42 |
+
trigger_error($this->layout->format($event), E_USER_ERROR);
|
43 |
+
} else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
|
44 |
+
trigger_error($this->layout->format($event), E_USER_WARNING);
|
45 |
+
} else {
|
46 |
+
trigger_error($this->layout->format($event), E_USER_NOTICE);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Log4php/appenders/LoggerAppenderRollingFile.php
ADDED
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* LoggerAppenderRollingFile writes logging events to a specified file. The
|
23 |
+
* file is rolled over after a specified size has been reached.
|
24 |
+
*
|
25 |
+
* This appender uses a layout.
|
26 |
+
*
|
27 |
+
* ## Configurable parameters: ##
|
28 |
+
*
|
29 |
+
* - **file** - Path to the target file.
|
30 |
+
* - **append** - If set to true, the appender will append to the file,
|
31 |
+
* otherwise the file contents will be overwritten.
|
32 |
+
* - **maxBackupIndex** - Maximum number of backup files to keep. Default is 1.
|
33 |
+
* - **maxFileSize** - Maximum allowed file size (in bytes) before rolling
|
34 |
+
* over. Suffixes "KB", "MB" and "GB" are allowed. 10KB = 10240 bytes, etc.
|
35 |
+
* Default is 10M.
|
36 |
+
* - **compress** - If set to true, rolled-over files will be compressed.
|
37 |
+
* Requires the zlib extension.
|
38 |
+
*
|
39 |
+
* @version $Revision: 1394975 $
|
40 |
+
* @package log4php
|
41 |
+
* @subpackage appenders
|
42 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
43 |
+
* @link http://logging.apache.org/log4php/docs/appenders/rolling-file.html Appender documentation
|
44 |
+
*/
|
45 |
+
class LoggerAppenderRollingFile extends LoggerAppenderFile {
|
46 |
+
|
47 |
+
/** Compressing backup files is done in chunks, this determines how large. */
|
48 |
+
const COMPRESS_CHUNK_SIZE = 102400; // 100KB
|
49 |
+
|
50 |
+
/**
|
51 |
+
* The maximum size (in bytes) that the output file is allowed to reach
|
52 |
+
* before being rolled over to backup files.
|
53 |
+
*
|
54 |
+
* The default maximum file size is 10MB (10485760 bytes). Maximum value
|
55 |
+
* for this option may depend on the file system.
|
56 |
+
*
|
57 |
+
* @var integer
|
58 |
+
*/
|
59 |
+
protected $maxFileSize = 10485760;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Set the maximum number of backup files to keep around.
|
63 |
+
*
|
64 |
+
* Determines how many backup files are kept before the oldest is erased.
|
65 |
+
* This option takes a positive integer value. If set to zero, then there
|
66 |
+
* will be no backup files and the log file will be truncated when it
|
67 |
+
* reaches <var>maxFileSize</var>.
|
68 |
+
*
|
69 |
+
* There is one backup file by default.
|
70 |
+
*
|
71 |
+
* @var integer
|
72 |
+
*/
|
73 |
+
protected $maxBackupIndex = 1;
|
74 |
+
|
75 |
+
/**
|
76 |
+
* The <var>compress</var> parameter determindes the compression with zlib.
|
77 |
+
* If set to true, the rollover files are compressed and saved with the .gz extension.
|
78 |
+
* @var boolean
|
79 |
+
*/
|
80 |
+
protected $compress = false;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Set to true in the constructor if PHP >= 5.3.0. In that case clearstatcache
|
84 |
+
* supports conditional clearing of statistics.
|
85 |
+
* @var boolean
|
86 |
+
* @see http://php.net/manual/en/function.clearstatcache.php
|
87 |
+
*/
|
88 |
+
private $clearConditional = false;
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get the maximum size that the output file is allowed to reach
|
92 |
+
* before being rolled over to backup files.
|
93 |
+
* @return integer
|
94 |
+
*/
|
95 |
+
public function getMaximumFileSize() {
|
96 |
+
return $this->maxFileSize;
|
97 |
+
}
|
98 |
+
|
99 |
+
public function __construct($name = '') {
|
100 |
+
parent::__construct($name);
|
101 |
+
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
|
102 |
+
$this->clearConditional = true;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Implements the usual roll over behaviour.
|
108 |
+
*
|
109 |
+
* If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex.
|
110 |
+
* Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
|
111 |
+
*
|
112 |
+
* If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
|
113 |
+
*
|
114 |
+
* Rollover must be called while the file is locked so that it is safe for concurrent access.
|
115 |
+
*
|
116 |
+
* @throws LoggerException If any part of the rollover procedure fails.
|
117 |
+
*/
|
118 |
+
private function rollOver() {
|
119 |
+
// If maxBackups <= 0, then there is no file renaming to be done.
|
120 |
+
if($this->maxBackupIndex > 0) {
|
121 |
+
// Delete the oldest file, to keep Windows happy.
|
122 |
+
$file = $this->file . '.' . $this->maxBackupIndex;
|
123 |
+
|
124 |
+
if (file_exists($file) && !unlink($file)) {
|
125 |
+
throw new LoggerException("Unable to delete oldest backup file from [$file].");
|
126 |
+
}
|
127 |
+
|
128 |
+
// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
|
129 |
+
$this->renameArchievedLogs($this->file);
|
130 |
+
|
131 |
+
// Backup the active file
|
132 |
+
$this->moveToBackup($this->file);
|
133 |
+
}
|
134 |
+
|
135 |
+
// Truncate the active file
|
136 |
+
ftruncate($this->fp, 0);
|
137 |
+
rewind($this->fp);
|
138 |
+
}
|
139 |
+
|
140 |
+
private function moveToBackup($source) {
|
141 |
+
if ($this->compress) {
|
142 |
+
$target = $source . '.1.gz';
|
143 |
+
$this->compressFile($source, $target);
|
144 |
+
} else {
|
145 |
+
$target = $source . '.1';
|
146 |
+
copy($source, $target);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
private function compressFile($source, $target) {
|
151 |
+
$target = 'compress.zlib://' . $target;
|
152 |
+
|
153 |
+
$fin = fopen($source, 'rb');
|
154 |
+
if ($fin === false) {
|
155 |
+
throw new LoggerException("Unable to open file for reading: [$source].");
|
156 |
+
}
|
157 |
+
|
158 |
+
$fout = fopen($target, 'wb');
|
159 |
+
if ($fout === false) {
|
160 |
+
throw new LoggerException("Unable to open file for writing: [$target].");
|
161 |
+
}
|
162 |
+
|
163 |
+
while (!feof($fin)) {
|
164 |
+
$chunk = fread($fin, self::COMPRESS_CHUNK_SIZE);
|
165 |
+
if (false === fwrite($fout, $chunk)) {
|
166 |
+
throw new LoggerException("Failed writing to compressed file.");
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
fclose($fin);
|
171 |
+
fclose($fout);
|
172 |
+
}
|
173 |
+
|
174 |
+
private function renameArchievedLogs($fileName) {
|
175 |
+
for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
|
176 |
+
|
177 |
+
$source = $fileName . "." . $i;
|
178 |
+
if ($this->compress) {
|
179 |
+
$source .= '.gz';
|
180 |
+
}
|
181 |
+
|
182 |
+
if(file_exists($source)) {
|
183 |
+
$target = $fileName . '.' . ($i + 1);
|
184 |
+
if ($this->compress) {
|
185 |
+
$target .= '.gz';
|
186 |
+
}
|
187 |
+
|
188 |
+
rename($source, $target);
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Writes a string to the target file. Opens file if not already open.
|
195 |
+
* @param string $string Data to write.
|
196 |
+
*/
|
197 |
+
protected function write($string) {
|
198 |
+
// Lazy file open
|
199 |
+
if(!isset($this->fp)) {
|
200 |
+
if ($this->openFile() === false) {
|
201 |
+
return; // Do not write if file open failed.
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
// Lock the file while writing and possible rolling over
|
206 |
+
if(flock($this->fp, LOCK_EX)) {
|
207 |
+
|
208 |
+
// Write to locked file
|
209 |
+
if(fwrite($this->fp, $string) === false) {
|
210 |
+
$this->warn("Failed writing to file. Closing appender.");
|
211 |
+
$this->closed = true;
|
212 |
+
}
|
213 |
+
|
214 |
+
// Stats cache must be cleared, otherwise filesize() returns cached results
|
215 |
+
// If supported (PHP 5.3+), clear only the state cache for the target file
|
216 |
+
if ($this->clearConditional) {
|
217 |
+
clearstatcache(true, $this->file);
|
218 |
+
} else {
|
219 |
+
clearstatcache();
|
220 |
+
}
|
221 |
+
|
222 |
+
// Rollover if needed
|
223 |
+
if (filesize($this->file) > $this->maxFileSize) {
|
224 |
+
try {
|
225 |
+
$this->rollOver();
|
226 |
+
} catch (LoggerException $ex) {
|
227 |
+
$this->warn("Rollover failed: " . $ex->getMessage() . " Closing appender.");
|
228 |
+
$this->closed = true;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
flock($this->fp, LOCK_UN);
|
233 |
+
} else {
|
234 |
+
$this->warn("Failed locking file for writing. Closing appender.");
|
235 |
+
$this->closed = true;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
public function activateOptions() {
|
240 |
+
parent::activateOptions();
|
241 |
+
|
242 |
+
if ($this->compress && !extension_loaded('zlib')) {
|
243 |
+
$this->warn("The 'zlib' extension is required for file compression. Disabling compression.");
|
244 |
+
$this->compression = false;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Set the 'maxBackupIndex' parameter.
|
250 |
+
* @param integer $maxBackupIndex
|
251 |
+
*/
|
252 |
+
public function setMaxBackupIndex($maxBackupIndex) {
|
253 |
+
$this->setPositiveInteger('maxBackupIndex', $maxBackupIndex);
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Returns the 'maxBackupIndex' parameter.
|
258 |
+
* @return integer
|
259 |
+
*/
|
260 |
+
public function getMaxBackupIndex() {
|
261 |
+
return $this->maxBackupIndex;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Set the 'maxFileSize' parameter.
|
266 |
+
* @param mixed $maxFileSize
|
267 |
+
*/
|
268 |
+
public function setMaxFileSize($maxFileSize) {
|
269 |
+
$this->setFileSize('maxFileSize', $maxFileSize);
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Returns the 'maxFileSize' parameter.
|
274 |
+
* @return integer
|
275 |
+
*/
|
276 |
+
public function getMaxFileSize() {
|
277 |
+
return $this->maxFileSize;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Set the 'maxFileSize' parameter (kept for backward compatibility).
|
282 |
+
* @param mixed $maxFileSize
|
283 |
+
* @deprecated Use setMaxFileSize() instead.
|
284 |
+
*/
|
285 |
+
public function setMaximumFileSize($maxFileSize) {
|
286 |
+
$this->warn("The 'maximumFileSize' parameter is deprecated. Use 'maxFileSize' instead.");
|
287 |
+
return $this->setMaxFileSize($maxFileSize);
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Sets the 'compress' parameter.
|
292 |
+
* @param boolean $compress
|
293 |
+
*/
|
294 |
+
public function setCompress($compress) {
|
295 |
+
$this->setBoolean('compress', $compress);
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Returns the 'compress' parameter.
|
300 |
+
* @param boolean
|
301 |
+
*/
|
302 |
+
public function getCompress() {
|
303 |
+
return $this->compress;
|
304 |
+
}
|
305 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderSocket.php
RENAMED
@@ -1,122 +1,122 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
* -
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
* @
|
34 |
-
* @
|
35 |
-
* @
|
36 |
-
*/
|
37 |
-
class LoggerAppenderSocket extends LoggerAppender {
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Target host.
|
41 |
-
* @see http://php.net/manual/en/function.fsockopen.php
|
42 |
-
*/
|
43 |
-
protected $remoteHost;
|
44 |
-
|
45 |
-
/** Target port */
|
46 |
-
protected $port = 4446;
|
47 |
-
|
48 |
-
/** Connection timeout in ms. */
|
49 |
-
protected $timeout;
|
50 |
-
|
51 |
-
// ******************************************
|
52 |
-
// *** Appender methods ***
|
53 |
-
// ******************************************
|
54 |
-
|
55 |
-
/** Override the default layout to use serialized. */
|
56 |
-
public function getDefaultLayout() {
|
57 |
-
return new LoggerLayoutSerialized();
|
58 |
-
}
|
59 |
-
|
60 |
-
public function activateOptions() {
|
61 |
-
if (empty($this->remoteHost)) {
|
62 |
-
$this->warn("Required parameter [remoteHost] not set. Closing appender.");
|
63 |
-
$this->closed = true;
|
64 |
-
return;
|
65 |
-
}
|
66 |
-
|
67 |
-
if (empty($this->timeout)) {
|
68 |
-
$this->timeout = ini_get("default_socket_timeout");
|
69 |
-
}
|
70 |
-
|
71 |
-
$this->closed = false;
|
72 |
-
}
|
73 |
-
|
74 |
-
public function append(LoggerLoggingEvent $event) {
|
75 |
-
$socket = fsockopen($this->remoteHost, $this->port, $errno, $errstr, $this->timeout);
|
76 |
-
if ($socket === false) {
|
77 |
-
$this->warn("Could not open socket to {$this->remoteHost}:{$this->port}. Closing appender.");
|
78 |
-
$this->closed = true;
|
79 |
-
return;
|
80 |
-
}
|
81 |
-
|
82 |
-
if (false === fwrite($socket, $this->layout->format($event))) {
|
83 |
-
$this->warn("Error writing to socket. Closing appender.");
|
84 |
-
$this->closed = true;
|
85 |
-
}
|
86 |
-
fclose($socket);
|
87 |
-
}
|
88 |
-
|
89 |
-
// ******************************************
|
90 |
-
// *** Accessor methods ***
|
91 |
-
// ******************************************
|
92 |
-
|
93 |
-
/** Sets the target host. */
|
94 |
-
public function setRemoteHost($hostname) {
|
95 |
-
$this->setString('remoteHost', $hostname);
|
96 |
-
}
|
97 |
-
|
98 |
-
/** Sets the target port */
|
99 |
-
public function setPort($port) {
|
100 |
-
$this->setPositiveInteger('port', $port);
|
101 |
-
}
|
102 |
-
|
103 |
-
/** Sets the timeout. */
|
104 |
-
public function setTimeout($timeout) {
|
105 |
-
$this->setPositiveInteger('timeout', $timeout);
|
106 |
-
}
|
107 |
-
|
108 |
-
/** Returns the target host. */
|
109 |
-
public function getRemoteHost() {
|
110 |
-
return $this->getRemoteHost();
|
111 |
-
}
|
112 |
-
|
113 |
-
/** Returns the target port. */
|
114 |
-
public function getPort() {
|
115 |
-
return $this->port;
|
116 |
-
}
|
117 |
-
|
118 |
-
/** Returns the timeout */
|
119 |
-
public function getTimeout() {
|
120 |
-
return $this->timeout;
|
121 |
-
}
|
122 |
-
}
|
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 |
+
|
19 |
+
/**
|
20 |
+
* LoggerAppenderSocket appends to a network socket.
|
21 |
+
*
|
22 |
+
* ## Configurable parameters: ##
|
23 |
+
*
|
24 |
+
* - **remoteHost** - Target remote host.
|
25 |
+
* - **port** - Target port (optional, defaults to 4446).
|
26 |
+
* - **timeout** - Connection timeout in seconds (optional, defaults to
|
27 |
+
* 'default_socket_timeout' from php.ini)
|
28 |
+
*
|
29 |
+
* The socket will by default be opened in blocking mode.
|
30 |
+
*
|
31 |
+
* @version $Revision: 1337820 $
|
32 |
+
* @package log4php
|
33 |
+
* @subpackage appenders
|
34 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
35 |
+
* @link http://logging.apache.org/log4php/docs/appenders/socket.html Appender documentation
|
36 |
+
*/
|
37 |
+
class LoggerAppenderSocket extends LoggerAppender {
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Target host.
|
41 |
+
* @see http://php.net/manual/en/function.fsockopen.php
|
42 |
+
*/
|
43 |
+
protected $remoteHost;
|
44 |
+
|
45 |
+
/** Target port */
|
46 |
+
protected $port = 4446;
|
47 |
+
|
48 |
+
/** Connection timeout in ms. */
|
49 |
+
protected $timeout;
|
50 |
+
|
51 |
+
// ******************************************
|
52 |
+
// *** Appender methods ***
|
53 |
+
// ******************************************
|
54 |
+
|
55 |
+
/** Override the default layout to use serialized. */
|
56 |
+
public function getDefaultLayout() {
|
57 |
+
return new LoggerLayoutSerialized();
|
58 |
+
}
|
59 |
+
|
60 |
+
public function activateOptions() {
|
61 |
+
if (empty($this->remoteHost)) {
|
62 |
+
$this->warn("Required parameter [remoteHost] not set. Closing appender.");
|
63 |
+
$this->closed = true;
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
if (empty($this->timeout)) {
|
68 |
+
$this->timeout = ini_get("default_socket_timeout");
|
69 |
+
}
|
70 |
+
|
71 |
+
$this->closed = false;
|
72 |
+
}
|
73 |
+
|
74 |
+
public function append(LoggerLoggingEvent $event) {
|
75 |
+
$socket = fsockopen($this->remoteHost, $this->port, $errno, $errstr, $this->timeout);
|
76 |
+
if ($socket === false) {
|
77 |
+
$this->warn("Could not open socket to {$this->remoteHost}:{$this->port}. Closing appender.");
|
78 |
+
$this->closed = true;
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
if (false === fwrite($socket, $this->layout->format($event))) {
|
83 |
+
$this->warn("Error writing to socket. Closing appender.");
|
84 |
+
$this->closed = true;
|
85 |
+
}
|
86 |
+
fclose($socket);
|
87 |
+
}
|
88 |
+
|
89 |
+
// ******************************************
|
90 |
+
// *** Accessor methods ***
|
91 |
+
// ******************************************
|
92 |
+
|
93 |
+
/** Sets the target host. */
|
94 |
+
public function setRemoteHost($hostname) {
|
95 |
+
$this->setString('remoteHost', $hostname);
|
96 |
+
}
|
97 |
+
|
98 |
+
/** Sets the target port */
|
99 |
+
public function setPort($port) {
|
100 |
+
$this->setPositiveInteger('port', $port);
|
101 |
+
}
|
102 |
+
|
103 |
+
/** Sets the timeout. */
|
104 |
+
public function setTimeout($timeout) {
|
105 |
+
$this->setPositiveInteger('timeout', $timeout);
|
106 |
+
}
|
107 |
+
|
108 |
+
/** Returns the target host. */
|
109 |
+
public function getRemoteHost() {
|
110 |
+
return $this->getRemoteHost();
|
111 |
+
}
|
112 |
+
|
113 |
+
/** Returns the target port. */
|
114 |
+
public function getPort() {
|
115 |
+
return $this->port;
|
116 |
+
}
|
117 |
+
|
118 |
+
/** Returns the timeout */
|
119 |
+
public function getTimeout() {
|
120 |
+
return $this->timeout;
|
121 |
+
}
|
122 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/appenders/LoggerAppenderSyslog.php
RENAMED
@@ -1,305 +1,303 @@
|
|
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 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
* -
|
30 |
-
* -
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
40 |
-
*
|
41 |
-
*
|
42 |
-
*
|
43 |
-
* Multiple options can be set by delimiting them with a pipe character,
|
44 |
-
* e.g.: "CONS|PID|PERROR".
|
45 |
-
*
|
46 |
-
* Recognised syslog priorities are:
|
47 |
-
*
|
48 |
-
*
|
49 |
-
*
|
50 |
-
*
|
51 |
-
*
|
52 |
-
*
|
53 |
-
*
|
54 |
-
*
|
55 |
-
*
|
56 |
-
*
|
57 |
-
*
|
58 |
-
*
|
59 |
-
* - <b>
|
60 |
-
* - <b>
|
61 |
-
* - <b>
|
62 |
-
* - <b>
|
63 |
-
*
|
64 |
-
*
|
65 |
-
*
|
66 |
-
*
|
67 |
-
*
|
68 |
-
*
|
69 |
-
*
|
70 |
-
* @
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
*
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
*
|
85 |
-
*
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
*
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
*
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
*
|
107 |
-
*
|
108 |
-
*
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
*
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
*
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
*
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
*
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
*
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
*
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
*
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
*
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
*
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
*
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
$this->
|
225 |
-
|
226 |
-
$this->
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
*
|
240 |
-
*
|
241 |
-
*
|
242 |
-
*
|
243 |
-
*
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
$
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
$options
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
$
|
274 |
-
}
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
}
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
}
|
305 |
-
}
|
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 |
+
|
19 |
+
/**
|
20 |
+
* Log events to a system log using the PHP syslog() function.
|
21 |
+
*
|
22 |
+
* This appenders requires a layout.
|
23 |
+
*
|
24 |
+
* ## Configurable parameters: ##
|
25 |
+
*
|
26 |
+
* - **ident** - The ident of the syslog message.
|
27 |
+
* - **priority** - The priority for the syslog message (used when overriding
|
28 |
+
* priority).
|
29 |
+
* - **facility** - The facility for the syslog message
|
30 |
+
* - **overridePriority** - If set to true, the message priority will always
|
31 |
+
* use the value defined in {@link $priority}, otherwise the priority will
|
32 |
+
* be determined by the message's log level.
|
33 |
+
* - **option** - The option value for the syslog message.
|
34 |
+
*
|
35 |
+
* Recognised syslog options are:
|
36 |
+
*
|
37 |
+
* - CONS - if there is an error while sending data to the system logger, write directly to the system console
|
38 |
+
* - NDELAY - open the connection to the logger immediately
|
39 |
+
* - ODELAY - delay opening the connection until the first message is logged (default)
|
40 |
+
* - PERROR - print log message also to standard error
|
41 |
+
* - PID - include PID with each message
|
42 |
+
*
|
43 |
+
* Multiple options can be set by delimiting them with a pipe character,
|
44 |
+
* e.g.: "CONS|PID|PERROR".
|
45 |
+
*
|
46 |
+
* Recognised syslog priorities are:
|
47 |
+
*
|
48 |
+
* - EMERG
|
49 |
+
* - ALERT
|
50 |
+
* - CRIT
|
51 |
+
* - ERR
|
52 |
+
* - WARNING
|
53 |
+
* - NOTICE
|
54 |
+
* - INFO
|
55 |
+
* - DEBUG
|
56 |
+
*
|
57 |
+
* Levels are mapped as follows:
|
58 |
+
*
|
59 |
+
* - <b>FATAL</b> to LOG_ALERT
|
60 |
+
* - <b>ERROR</b> to LOG_ERR
|
61 |
+
* - <b>WARN</b> to LOG_WARNING
|
62 |
+
* - <b>INFO</b> to LOG_INFO
|
63 |
+
* - <b>DEBUG</b> to LOG_DEBUG
|
64 |
+
* - <b>TRACE</b> to LOG_DEBUG
|
65 |
+
*
|
66 |
+
* @version $Revision: 1337820 $
|
67 |
+
* @package log4php
|
68 |
+
* @subpackage appenders
|
69 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
70 |
+
* @link http://logging.apache.org/log4php/docs/appenders/syslog.html Appender documentation
|
71 |
+
*/
|
72 |
+
class LoggerAppenderSyslog extends LoggerAppender {
|
73 |
+
|
74 |
+
/**
|
75 |
+
* The ident string is added to each message. Typically the name of your application.
|
76 |
+
*
|
77 |
+
* @var string
|
78 |
+
*/
|
79 |
+
protected $ident = "Apache log4php";
|
80 |
+
|
81 |
+
/**
|
82 |
+
* The syslog priority to use when overriding priority. This setting is
|
83 |
+
* required if {@link overridePriority} is set to true.
|
84 |
+
*
|
85 |
+
* @var string
|
86 |
+
*/
|
87 |
+
protected $priority;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* The option used when opening the syslog connection.
|
91 |
+
*
|
92 |
+
* @var string
|
93 |
+
*/
|
94 |
+
protected $option = 'PID|CONS';
|
95 |
+
|
96 |
+
/**
|
97 |
+
* The facility value indicates the source of the message.
|
98 |
+
*
|
99 |
+
* @var string
|
100 |
+
*/
|
101 |
+
protected $facility = 'USER';
|
102 |
+
|
103 |
+
/**
|
104 |
+
* If set to true, the message priority will always use the value defined
|
105 |
+
* in {@link $priority}, otherwise the priority will be determined by the
|
106 |
+
* message's log level.
|
107 |
+
*
|
108 |
+
* @var string
|
109 |
+
*/
|
110 |
+
protected $overridePriority = false;
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Holds the int value of the {@link $priority}.
|
114 |
+
* @var int
|
115 |
+
*/
|
116 |
+
private $intPriority;
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Holds the int value of the {@link $facility}.
|
120 |
+
* @var int
|
121 |
+
*/
|
122 |
+
private $intFacility;
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Holds the int value of the {@link $option}.
|
126 |
+
* @var int
|
127 |
+
*/
|
128 |
+
private $intOption;
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Sets the {@link $ident}.
|
132 |
+
*
|
133 |
+
* @param string $ident
|
134 |
+
*/
|
135 |
+
public function setIdent($ident) {
|
136 |
+
$this->ident = $ident;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Sets the {@link $priority}.
|
141 |
+
*
|
142 |
+
* @param string $priority
|
143 |
+
*/
|
144 |
+
public function setPriority($priority) {
|
145 |
+
$this->priority = $priority;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Sets the {@link $facility}.
|
150 |
+
*
|
151 |
+
* @param string $facility
|
152 |
+
*/
|
153 |
+
public function setFacility($facility) {
|
154 |
+
$this->facility = $facility;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Sets the {@link $overridePriority}.
|
159 |
+
*
|
160 |
+
* @param string $overridePriority
|
161 |
+
*/
|
162 |
+
public function setOverridePriority($overridePriority) {
|
163 |
+
$this->overridePriority = $overridePriority;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Sets the 'option' parameter.
|
168 |
+
*
|
169 |
+
* @param string $option
|
170 |
+
*/
|
171 |
+
public function setOption($option) {
|
172 |
+
$this->option = $option;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Returns the 'ident' parameter.
|
177 |
+
*
|
178 |
+
* @return string $ident
|
179 |
+
*/
|
180 |
+
public function getIdent() {
|
181 |
+
return $this->ident;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Returns the 'priority' parameter.
|
186 |
+
*
|
187 |
+
* @return string
|
188 |
+
*/
|
189 |
+
public function getPriority() {
|
190 |
+
return $this->priority;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Returns the 'facility' parameter.
|
195 |
+
*
|
196 |
+
* @return string
|
197 |
+
*/
|
198 |
+
public function getFacility() {
|
199 |
+
return $this->facility;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Returns the 'overridePriority' parameter.
|
204 |
+
*
|
205 |
+
* @return string
|
206 |
+
*/
|
207 |
+
public function getOverridePriority() {
|
208 |
+
return $this->overridePriority;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Returns the 'option' parameter.
|
213 |
+
*
|
214 |
+
* @return string
|
215 |
+
*/
|
216 |
+
public function getOption() {
|
217 |
+
return $this->option;
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
public function activateOptions() {
|
222 |
+
$this->intPriority = $this->parsePriority();
|
223 |
+
$this->intOption = $this->parseOption();
|
224 |
+
$this->intFacility = $this->parseFacility();
|
225 |
+
|
226 |
+
$this->closed = false;
|
227 |
+
}
|
228 |
+
|
229 |
+
public function close() {
|
230 |
+
if($this->closed != true) {
|
231 |
+
closelog();
|
232 |
+
$this->closed = true;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Appends the event to syslog.
|
238 |
+
*
|
239 |
+
* Log is opened and closed each time because if it is not closed, it
|
240 |
+
* can cause the Apache httpd server to log to whatever ident/facility
|
241 |
+
* was used in openlog().
|
242 |
+
*
|
243 |
+
* @see http://www.php.net/manual/en/function.syslog.php#97843
|
244 |
+
*/
|
245 |
+
public function append(LoggerLoggingEvent $event) {
|
246 |
+
$priority = $this->getSyslogPriority($event->getLevel());
|
247 |
+
$message = $this->layout->format($event);
|
248 |
+
|
249 |
+
openlog($this->ident, $this->intOption, $this->intFacility);
|
250 |
+
syslog($priority, $message);
|
251 |
+
closelog();
|
252 |
+
}
|
253 |
+
|
254 |
+
/** Determines which syslog priority to use based on the given level. */
|
255 |
+
private function getSyslogPriority(LoggerLevel $level) {
|
256 |
+
if($this->overridePriority) {
|
257 |
+
return $this->intPriority;
|
258 |
+
}
|
259 |
+
return $level->getSyslogEquivalent();
|
260 |
+
}
|
261 |
+
|
262 |
+
/** Parses a syslog option string and returns the correspodning int value. */
|
263 |
+
private function parseOption() {
|
264 |
+
$value = 0;
|
265 |
+
$options = explode('|', $this->option);
|
266 |
+
|
267 |
+
foreach($options as $option) {
|
268 |
+
if (!empty($option)) {
|
269 |
+
$constant = "LOG_" . trim($option);
|
270 |
+
if (defined($constant)) {
|
271 |
+
$value |= constant($constant);
|
272 |
+
} else {
|
273 |
+
trigger_error("log4php: Invalid syslog option provided: $option. Whole option string: {$this->option}.", E_USER_WARNING);
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
return $value;
|
278 |
+
}
|
279 |
+
|
280 |
+
/** Parses the facility string and returns the corresponding int value. */
|
281 |
+
private function parseFacility() {
|
282 |
+
if (!empty($this->facility)) {
|
283 |
+
$constant = "LOG_" . trim($this->facility);
|
284 |
+
if (defined($constant)) {
|
285 |
+
return constant($constant);
|
286 |
+
} else {
|
287 |
+
trigger_error("log4php: Invalid syslog facility provided: {$this->facility}.", E_USER_WARNING);
|
288 |
+
}
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
/** Parses the priority string and returns the corresponding int value. */
|
293 |
+
private function parsePriority() {
|
294 |
+
if (!empty($this->priority)) {
|
295 |
+
$constant = "LOG_" . trim($this->priority);
|
296 |
+
if (defined($constant)) {
|
297 |
+
return constant($constant);
|
298 |
+
} else {
|
299 |
+
trigger_error("log4php: Invalid syslog priority provided: {$this->priority}.", E_USER_WARNING);
|
300 |
+
}
|
301 |
+
}
|
302 |
+
}
|
303 |
+
}
|
|
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfigurationAdapter.php
RENAMED
@@ -27,7 +27,7 @@
|
|
27 |
* @package log4php
|
28 |
* @subpackage configurators
|
29 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
30 |
-
* @version $Revision$
|
31 |
* @since 2.2
|
32 |
*/
|
33 |
interface LoggerConfigurationAdapter
|
@@ -37,4 +37,3 @@ interface LoggerConfigurationAdapter
|
|
37 |
|
38 |
}
|
39 |
|
40 |
-
?>
|
27 |
* @package log4php
|
28 |
* @subpackage configurators
|
29 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
30 |
+
* @version $Revision: 1343601 $
|
31 |
* @since 2.2
|
32 |
*/
|
33 |
interface LoggerConfigurationAdapter
|
37 |
|
38 |
}
|
39 |
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfigurationAdapterINI.php
RENAMED
@@ -27,7 +27,7 @@
|
|
27 |
* @package log4php
|
28 |
* @subpackage configurators
|
29 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
30 |
-
* @version $Revision$
|
31 |
* @since 2.2
|
32 |
*/
|
33 |
class LoggerConfigurationAdapterINI implements LoggerConfigurationAdapter {
|
@@ -59,12 +59,6 @@ class LoggerConfigurationAdapterINI implements LoggerConfigurationAdapter {
|
|
59 |
/**
|
60 |
* Loads and parses the INI configuration file.
|
61 |
*
|
62 |
-
* INI_SCANNER_RAW is used here because otherwise parse_ini_file() will
|
63 |
-
* try to parse all values, with some strange results. For example, "true"
|
64 |
-
* will become "1", while "false" and "null" will become "" (empty string).
|
65 |
-
*
|
66 |
-
* @see http://php.net/manual/en/function.parse-ini-file.php
|
67 |
-
*
|
68 |
* @param string $url Path to the config file.
|
69 |
* @throws LoggerException
|
70 |
*/
|
@@ -303,4 +297,3 @@ class LoggerConfigurationAdapterINI implements LoggerConfigurationAdapter {
|
|
303 |
|
304 |
}
|
305 |
|
306 |
-
?>
|
27 |
* @package log4php
|
28 |
* @subpackage configurators
|
29 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
30 |
+
* @version $Revision: 1343601 $
|
31 |
* @since 2.2
|
32 |
*/
|
33 |
class LoggerConfigurationAdapterINI implements LoggerConfigurationAdapter {
|
59 |
/**
|
60 |
* Loads and parses the INI configuration file.
|
61 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
* @param string $url Path to the config file.
|
63 |
* @throws LoggerException
|
64 |
*/
|
297 |
|
298 |
}
|
299 |
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfigurationAdapterPHP.php
RENAMED
@@ -46,7 +46,7 @@
|
|
46 |
* @package log4php
|
47 |
* @subpackage configurators
|
48 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
49 |
-
* @version $Revision$
|
50 |
* @since 2.2
|
51 |
*/
|
52 |
class LoggerConfigurationAdapterPHP implements LoggerConfigurationAdapter
|
@@ -82,4 +82,3 @@ class LoggerConfigurationAdapterPHP implements LoggerConfigurationAdapter
|
|
82 |
}
|
83 |
}
|
84 |
|
85 |
-
?>
|
46 |
* @package log4php
|
47 |
* @subpackage configurators
|
48 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
49 |
+
* @version $Revision: 1343601 $
|
50 |
* @since 2.2
|
51 |
*/
|
52 |
class LoggerConfigurationAdapterPHP implements LoggerConfigurationAdapter
|
82 |
}
|
83 |
}
|
84 |
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfigurationAdapterXML.php
RENAMED
@@ -24,7 +24,7 @@
|
|
24 |
* @package log4php
|
25 |
* @subpackage configurators
|
26 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
27 |
-
* @version $Revision$
|
28 |
* @since 2.2
|
29 |
*/
|
30 |
class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
@@ -38,8 +38,7 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
|
38 |
'renderers' => array(),
|
39 |
);
|
40 |
|
41 |
-
public function convert($url)
|
42 |
-
{
|
43 |
$xml = $this->loadXML($url);
|
44 |
|
45 |
$this->parseConfiguration($xml);
|
@@ -63,6 +62,12 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
|
63 |
foreach($xml->renderer as $rendererNode) {
|
64 |
$this->parseRenderer($rendererNode);
|
65 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
return $this->config;
|
67 |
}
|
68 |
|
@@ -174,10 +179,7 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
|
174 |
$logger['level'] = $this->getAttributeValue($node->level, 'value');
|
175 |
}
|
176 |
|
177 |
-
$logger['appenders'] =
|
178 |
-
foreach($node->appender_ref as $appender) {
|
179 |
-
$logger['appenders'][] = $this->getAttributeValue($appender, 'ref');
|
180 |
-
}
|
181 |
|
182 |
$this->config['rootLogger'] = $logger;
|
183 |
}
|
@@ -200,7 +202,7 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
|
200 |
$logger['additivity'] = $this->getAttributeValue($node, 'additivity');
|
201 |
}
|
202 |
|
203 |
-
$logger['appenders'] = $this->parseAppenderReferences($node
|
204 |
|
205 |
// Check for duplicate loggers
|
206 |
if (isset($this->config['loggers'][$name])) {
|
@@ -212,13 +214,20 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
|
212 |
|
213 |
/**
|
214 |
* Parses a <logger> node for appender references and returns them in an array.
|
|
|
|
|
|
|
215 |
*/
|
216 |
-
private function parseAppenderReferences(SimpleXMLElement $node
|
217 |
$refs = array();
|
218 |
foreach($node->appender_ref as $ref) {
|
219 |
$refs[] = $this->getAttributeValue($ref, 'ref');
|
220 |
}
|
221 |
|
|
|
|
|
|
|
|
|
222 |
return $refs;
|
223 |
}
|
224 |
|
@@ -242,6 +251,18 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
|
242 |
$this->config['renderers'][] = compact('renderedClass', 'renderingClass');
|
243 |
}
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
// ******************************************
|
246 |
// ** Helper methods **
|
247 |
// ******************************************
|
@@ -255,4 +276,3 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
|
255 |
}
|
256 |
}
|
257 |
|
258 |
-
?>
|
24 |
* @package log4php
|
25 |
* @subpackage configurators
|
26 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
27 |
+
* @version $Revision: 1394956 $
|
28 |
* @since 2.2
|
29 |
*/
|
30 |
class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
|
38 |
'renderers' => array(),
|
39 |
);
|
40 |
|
41 |
+
public function convert($url) {
|
|
|
42 |
$xml = $this->loadXML($url);
|
43 |
|
44 |
$this->parseConfiguration($xml);
|
62 |
foreach($xml->renderer as $rendererNode) {
|
63 |
$this->parseRenderer($rendererNode);
|
64 |
}
|
65 |
+
|
66 |
+
// Process <defaultRenderer> node
|
67 |
+
foreach($xml->defaultRenderer as $rendererNode) {
|
68 |
+
$this->parseDefaultRenderer($rendererNode);
|
69 |
+
}
|
70 |
+
|
71 |
return $this->config;
|
72 |
}
|
73 |
|
179 |
$logger['level'] = $this->getAttributeValue($node->level, 'value');
|
180 |
}
|
181 |
|
182 |
+
$logger['appenders'] = $this->parseAppenderReferences($node);
|
|
|
|
|
|
|
183 |
|
184 |
$this->config['rootLogger'] = $logger;
|
185 |
}
|
202 |
$logger['additivity'] = $this->getAttributeValue($node, 'additivity');
|
203 |
}
|
204 |
|
205 |
+
$logger['appenders'] = $this->parseAppenderReferences($node);
|
206 |
|
207 |
// Check for duplicate loggers
|
208 |
if (isset($this->config['loggers'][$name])) {
|
214 |
|
215 |
/**
|
216 |
* Parses a <logger> node for appender references and returns them in an array.
|
217 |
+
*
|
218 |
+
* Previous versions supported appender-ref, as well as appender_ref so both
|
219 |
+
* are parsed for backward compatibility.
|
220 |
*/
|
221 |
+
private function parseAppenderReferences(SimpleXMLElement $node) {
|
222 |
$refs = array();
|
223 |
foreach($node->appender_ref as $ref) {
|
224 |
$refs[] = $this->getAttributeValue($ref, 'ref');
|
225 |
}
|
226 |
|
227 |
+
foreach($node->{'appender-ref'} as $ref) {
|
228 |
+
$refs[] = $this->getAttributeValue($ref, 'ref');
|
229 |
+
}
|
230 |
+
|
231 |
return $refs;
|
232 |
}
|
233 |
|
251 |
$this->config['renderers'][] = compact('renderedClass', 'renderingClass');
|
252 |
}
|
253 |
|
254 |
+
/** Parses a <defaultRenderer> node. */
|
255 |
+
private function parseDefaultRenderer(SimpleXMLElement $node) {
|
256 |
+
$renderingClass = $this->getAttributeValue($node, 'renderingClass');
|
257 |
+
|
258 |
+
// Warn on duplicates
|
259 |
+
if(isset($this->config['defaultRenderer'])) {
|
260 |
+
$this->warn("Duplicate <defaultRenderer> node. Overwriting.");
|
261 |
+
}
|
262 |
+
|
263 |
+
$this->config['defaultRenderer'] = $renderingClass;
|
264 |
+
}
|
265 |
+
|
266 |
// ******************************************
|
267 |
// ** Helper methods **
|
268 |
// ******************************************
|
276 |
}
|
277 |
}
|
278 |
|
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/configurators/LoggerConfiguratorDefault.php
RENAMED
@@ -25,7 +25,7 @@
|
|
25 |
*
|
26 |
* @package log4php
|
27 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
28 |
-
* @version $Revision:
|
29 |
* @since 2.2
|
30 |
*/
|
31 |
class LoggerConfiguratorDefault implements LoggerConfigurator
|
@@ -55,10 +55,7 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
|
|
55 |
),
|
56 |
'appenders' => array(
|
57 |
'default' => array(
|
58 |
-
'class' => 'LoggerAppenderEcho'
|
59 |
-
'layout' => array(
|
60 |
-
'class' => 'LoggerLayoutTTCC',
|
61 |
-
),
|
62 |
),
|
63 |
),
|
64 |
);
|
@@ -100,8 +97,7 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
|
|
100 |
* will be used.
|
101 |
* @return array The parsed configuration.
|
102 |
*/
|
103 |
-
public function parse($input)
|
104 |
-
{
|
105 |
// No input - use default configuration
|
106 |
if (!isset($input)) {
|
107 |
$config = self::$defaultConfiguration;
|
@@ -224,38 +220,35 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
|
|
224 |
$this->configureRenderer($hierarchy, $rendererConfig);
|
225 |
}
|
226 |
}
|
|
|
|
|
|
|
|
|
227 |
}
|
228 |
|
229 |
private function configureRenderer(LoggerHierarchy $hierarchy, $config) {
|
230 |
-
if (
|
231 |
-
$this->warn("Rendering class not specified. Skipping
|
232 |
-
return;
|
233 |
}
|
234 |
|
235 |
-
|
236 |
-
|
237 |
-
$this->warn("Nonexistant rendering class [$renderingClass] specified. Skipping renderers definition.");
|
238 |
return;
|
239 |
}
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
return;
|
245 |
-
}
|
246 |
|
247 |
-
|
248 |
-
|
249 |
-
|
|
|
250 |
}
|
251 |
|
252 |
-
|
253 |
-
|
254 |
-
$this->warn("Nonexistant rendered class [$renderedClass] specified for renderer [$renderingClass]. Skipping renderers definition.");
|
255 |
-
return;
|
256 |
-
}
|
257 |
-
|
258 |
-
$hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClassInstance);
|
259 |
}
|
260 |
|
261 |
/**
|
@@ -416,7 +409,6 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
|
|
416 |
if (isset($level)) {
|
417 |
$logger->setLevel($level);
|
418 |
} else {
|
419 |
-
$default = $logger->getLevel();
|
420 |
$this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
|
421 |
}
|
422 |
}
|
@@ -434,10 +426,10 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
|
|
434 |
|
435 |
// Set logger additivity
|
436 |
if (isset($config['additivity'])) {
|
437 |
-
|
438 |
-
|
439 |
$logger->setAdditivity($additivity);
|
440 |
-
}
|
441 |
$this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
|
442 |
}
|
443 |
}
|
@@ -482,4 +474,4 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
|
|
482 |
private function warn($message) {
|
483 |
trigger_error("log4php: $message", E_USER_WARNING);
|
484 |
}
|
485 |
-
}
|
25 |
*
|
26 |
* @package log4php
|
27 |
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
28 |
+
* @version $Revision: 1394956 $
|
29 |
* @since 2.2
|
30 |
*/
|
31 |
class LoggerConfiguratorDefault implements LoggerConfigurator
|
55 |
),
|
56 |
'appenders' => array(
|
57 |
'default' => array(
|
58 |
+
'class' => 'LoggerAppenderEcho'
|
|
|
|
|
|
|
59 |
),
|
60 |
),
|
61 |
);
|
97 |
* will be used.
|
98 |
* @return array The parsed configuration.
|
99 |
*/
|
100 |
+
public function parse($input) {
|
|
|
101 |
// No input - use default configuration
|
102 |
if (!isset($input)) {
|
103 |
$config = self::$defaultConfiguration;
|
220 |
$this->configureRenderer($hierarchy, $rendererConfig);
|
221 |
}
|
222 |
}
|
223 |
+
|
224 |
+
if (isset($config['defaultRenderer'])) {
|
225 |
+
$this->configureDefaultRenderer($hierarchy, $config['defaultRenderer']);
|
226 |
+
}
|
227 |
}
|
228 |
|
229 |
private function configureRenderer(LoggerHierarchy $hierarchy, $config) {
|
230 |
+
if (empty($config['renderingClass'])) {
|
231 |
+
$this->warn("Rendering class not specified. Skipping renderer definition.");
|
232 |
+
return;
|
233 |
}
|
234 |
|
235 |
+
if (empty($config['renderedClass'])) {
|
236 |
+
$this->warn("Rendered class not specified. Skipping renderer definition.");
|
|
|
237 |
return;
|
238 |
}
|
239 |
|
240 |
+
// Error handling performed by RendererMap
|
241 |
+
$hierarchy->getRendererMap()->addRenderer($config['renderedClass'], $config['renderingClass']);
|
242 |
+
}
|
|
|
|
|
243 |
|
244 |
+
private function configureDefaultRenderer(LoggerHierarchy $hierarchy, $class) {
|
245 |
+
if (empty($class)) {
|
246 |
+
$this->warn("Rendering class not specified. Skipping default renderer definition.");
|
247 |
+
return;
|
248 |
}
|
249 |
|
250 |
+
// Error handling performed by RendererMap
|
251 |
+
$hierarchy->getRendererMap()->setDefaultRenderer($class);
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
253 |
|
254 |
/**
|
409 |
if (isset($level)) {
|
410 |
$logger->setLevel($level);
|
411 |
} else {
|
|
|
412 |
$this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
|
413 |
}
|
414 |
}
|
426 |
|
427 |
// Set logger additivity
|
428 |
if (isset($config['additivity'])) {
|
429 |
+
try {
|
430 |
+
$additivity = LoggerOptionConverter::toBooleanEx($config['additivity'], null);
|
431 |
$logger->setAdditivity($additivity);
|
432 |
+
} catch (Exception $ex) {
|
433 |
$this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
|
434 |
}
|
435 |
}
|
474 |
private function warn($message) {
|
475 |
trigger_error("log4php: $message", E_USER_WARNING);
|
476 |
}
|
477 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/filters/LoggerFilterDenyAll.php
RENAMED
@@ -1,56 +1,56 @@
|
|
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 |
-
/**
|
22 |
-
* This filter drops all logging events.
|
23 |
-
*
|
24 |
-
* You can add this filter to the end of a filter chain to
|
25 |
-
* switch from the default "accept all unless instructed otherwise"
|
26 |
-
* filtering behaviour to a "deny all unless instructed otherwise"
|
27 |
-
* behaviour.
|
28 |
-
*
|
29 |
-
* <p>
|
30 |
-
* An example for this filter:
|
31 |
-
*
|
32 |
-
* {@example ../../examples/php/filter_denyall.php 19}
|
33 |
-
*
|
34 |
-
* <p>
|
35 |
-
* The corresponding XML file:
|
36 |
-
*
|
37 |
-
* {@example ../../examples/resources/filter_denyall.xml 18}
|
38 |
-
*
|
39 |
-
* @version $Revision: 883108 $
|
40 |
-
* @package log4php
|
41 |
-
* @subpackage filters
|
42 |
-
* @since 0.3
|
43 |
-
*/
|
44 |
-
class LoggerFilterDenyAll extends LoggerFilter {
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Always returns the integer constant {@link LoggerFilter::DENY}
|
48 |
-
* regardless of the {@link LoggerLoggingEvent} parameter.
|
49 |
-
*
|
50 |
-
* @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter.
|
51 |
-
* @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY}
|
52 |
-
*/
|
53 |
-
public function decide(LoggerLoggingEvent $event) {
|
54 |
-
return LoggerFilter::DENY;
|
55 |
-
}
|
56 |
-
}
|
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 |
+
/**
|
22 |
+
* This filter drops all logging events.
|
23 |
+
*
|
24 |
+
* You can add this filter to the end of a filter chain to
|
25 |
+
* switch from the default "accept all unless instructed otherwise"
|
26 |
+
* filtering behaviour to a "deny all unless instructed otherwise"
|
27 |
+
* behaviour.
|
28 |
+
*
|
29 |
+
* <p>
|
30 |
+
* An example for this filter:
|
31 |
+
*
|
32 |
+
* {@example ../../examples/php/filter_denyall.php 19}
|
33 |
+
*
|
34 |
+
* <p>
|
35 |
+
* The corresponding XML file:
|
36 |
+
*
|
37 |
+
* {@example ../../examples/resources/filter_denyall.xml 18}
|
38 |
+
*
|
39 |
+
* @version $Revision: 883108 $
|
40 |
+
* @package log4php
|
41 |
+
* @subpackage filters
|
42 |
+
* @since 0.3
|
43 |
+
*/
|
44 |
+
class LoggerFilterDenyAll extends LoggerFilter {
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Always returns the integer constant {@link LoggerFilter::DENY}
|
48 |
+
* regardless of the {@link LoggerLoggingEvent} parameter.
|
49 |
+
*
|
50 |
+
* @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to filter.
|
51 |
+
* @return LoggerFilter::DENY Always returns {@link LoggerFilter::DENY}
|
52 |
+
*/
|
53 |
+
public function decide(LoggerLoggingEvent $event) {
|
54 |
+
return LoggerFilter::DENY;
|
55 |
+
}
|
56 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/filters/LoggerFilterLevelMatch.php
RENAMED
@@ -1,100 +1,100 @@
|
|
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 |
-
/**
|
22 |
-
* This is a very simple filter based on level matching.
|
23 |
-
*
|
24 |
-
* <p>The filter admits two options <b><var>LevelToMatch</var></b> and
|
25 |
-
* <b><var>AcceptOnMatch</var></b>. If there is an exact match between the value
|
26 |
-
* of the <b><var>LevelToMatch</var></b> option and the level of the
|
27 |
-
* {@link LoggerLoggingEvent}, then the {@link decide()} method returns
|
28 |
-
* {@link LoggerFilter::ACCEPT} in case the <b><var>AcceptOnMatch</var></b>
|
29 |
-
* option value is set to <i>true</i>, if it is <i>false</i> then
|
30 |
-
* {@link LoggerFilter::DENY} is returned. If there is no match,
|
31 |
-
* {@link LoggerFilter::NEUTRAL} is returned.</p>
|
32 |
-
*
|
33 |
-
* <p>
|
34 |
-
* An example for this filter:
|
35 |
-
*
|
36 |
-
* {@example ../../examples/php/filter_levelmatch.php 19}
|
37 |
-
*
|
38 |
-
* <p>
|
39 |
-
* The corresponding XML file:
|
40 |
-
*
|
41 |
-
* {@example ../../examples/resources/filter_levelmatch.xml 18}
|
42 |
-
*
|
43 |
-
* @version $Revision: 1213283 $
|
44 |
-
* @package log4php
|
45 |
-
* @subpackage filters
|
46 |
-
* @since 0.6
|
47 |
-
*/
|
48 |
-
class LoggerFilterLevelMatch extends LoggerFilter {
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Indicates if this event should be accepted or denied on match
|
52 |
-
* @var boolean
|
53 |
-
*/
|
54 |
-
protected $acceptOnMatch = true;
|
55 |
-
|
56 |
-
/**
|
57 |
-
* The level, when to match
|
58 |
-
* @var LoggerLevel
|
59 |
-
*/
|
60 |
-
protected $levelToMatch;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* @param boolean $acceptOnMatch
|
64 |
-
*/
|
65 |
-
public function setAcceptOnMatch($acceptOnMatch) {
|
66 |
-
$this->setBoolean('acceptOnMatch', $acceptOnMatch);
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @param string $l the level to match
|
71 |
-
*/
|
72 |
-
public function setLevelToMatch($level) {
|
73 |
-
$this->setLevel('levelToMatch', $level);
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Return the decision of this filter.
|
78 |
-
*
|
79 |
-
* Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b>
|
80 |
-
* option is not set or if there is not match. Otherwise, if there is a
|
81 |
-
* match, then the returned decision is {@link LoggerFilter::ACCEPT} if the
|
82 |
-
* <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
|
83 |
-
* returned decision is {@link LoggerFilter::DENY} if the
|
84 |
-
* <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
|
85 |
-
*
|
86 |
-
* @param LoggerLoggingEvent $event
|
87 |
-
* @return integer
|
88 |
-
*/
|
89 |
-
public function decide(LoggerLoggingEvent $event) {
|
90 |
-
if($this->levelToMatch === null) {
|
91 |
-
return LoggerFilter::NEUTRAL;
|
92 |
-
}
|
93 |
-
|
94 |
-
if($this->levelToMatch->equals($event->getLevel())) {
|
95 |
-
return $this->acceptOnMatch ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
|
96 |
-
} else {
|
97 |
-
return LoggerFilter::NEUTRAL;
|
98 |
-
}
|
99 |
-
}
|
100 |
-
}
|
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 |
+
/**
|
22 |
+
* This is a very simple filter based on level matching.
|
23 |
+
*
|
24 |
+
* <p>The filter admits two options <b><var>LevelToMatch</var></b> and
|
25 |
+
* <b><var>AcceptOnMatch</var></b>. If there is an exact match between the value
|
26 |
+
* of the <b><var>LevelToMatch</var></b> option and the level of the
|
27 |
+
* {@link LoggerLoggingEvent}, then the {@link decide()} method returns
|
28 |
+
* {@link LoggerFilter::ACCEPT} in case the <b><var>AcceptOnMatch</var></b>
|
29 |
+
* option value is set to <i>true</i>, if it is <i>false</i> then
|
30 |
+
* {@link LoggerFilter::DENY} is returned. If there is no match,
|
31 |
+
* {@link LoggerFilter::NEUTRAL} is returned.</p>
|
32 |
+
*
|
33 |
+
* <p>
|
34 |
+
* An example for this filter:
|
35 |
+
*
|
36 |
+
* {@example ../../examples/php/filter_levelmatch.php 19}
|
37 |
+
*
|
38 |
+
* <p>
|
39 |
+
* The corresponding XML file:
|
40 |
+
*
|
41 |
+
* {@example ../../examples/resources/filter_levelmatch.xml 18}
|
42 |
+
*
|
43 |
+
* @version $Revision: 1213283 $
|
44 |
+
* @package log4php
|
45 |
+
* @subpackage filters
|
46 |
+
* @since 0.6
|
47 |
+
*/
|
48 |
+
class LoggerFilterLevelMatch extends LoggerFilter {
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Indicates if this event should be accepted or denied on match
|
52 |
+
* @var boolean
|
53 |
+
*/
|
54 |
+
protected $acceptOnMatch = true;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* The level, when to match
|
58 |
+
* @var LoggerLevel
|
59 |
+
*/
|
60 |
+
protected $levelToMatch;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param boolean $acceptOnMatch
|
64 |
+
*/
|
65 |
+
public function setAcceptOnMatch($acceptOnMatch) {
|
66 |
+
$this->setBoolean('acceptOnMatch', $acceptOnMatch);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @param string $l the level to match
|
71 |
+
*/
|
72 |
+
public function setLevelToMatch($level) {
|
73 |
+
$this->setLevel('levelToMatch', $level);
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Return the decision of this filter.
|
78 |
+
*
|
79 |
+
* Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b>
|
80 |
+
* option is not set or if there is not match. Otherwise, if there is a
|
81 |
+
* match, then the returned decision is {@link LoggerFilter::ACCEPT} if the
|
82 |
+
* <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
|
83 |
+
* returned decision is {@link LoggerFilter::DENY} if the
|
84 |
+
* <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
|
85 |
+
*
|
86 |
+
* @param LoggerLoggingEvent $event
|
87 |
+
* @return integer
|
88 |
+
*/
|
89 |
+
public function decide(LoggerLoggingEvent $event) {
|
90 |
+
if($this->levelToMatch === null) {
|
91 |
+
return LoggerFilter::NEUTRAL;
|
92 |
+
}
|
93 |
+
|
94 |
+
if($this->levelToMatch->equals($event->getLevel())) {
|
95 |
+
return $this->acceptOnMatch ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
|
96 |
+
} else {
|
97 |
+
return LoggerFilter::NEUTRAL;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/filters/LoggerFilterLevelRange.php
RENAMED
@@ -1,138 +1,138 @@
|
|
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 |
-
/**
|
22 |
-
* This is a very simple filter based on level matching, which can be
|
23 |
-
* used to reject messages with priorities outside a certain range.
|
24 |
-
*
|
25 |
-
* <p>The filter admits three options <b><var>LevelMin</var></b>, <b><var>LevelMax</var></b>
|
26 |
-
* and <b><var>AcceptOnMatch</var></b>.</p>
|
27 |
-
*
|
28 |
-
* <p>If the level of the {@link LoggerLoggingEvent} is not between Min and Max
|
29 |
-
* (inclusive), then {@link LoggerFilter::DENY} is returned.</p>
|
30 |
-
*
|
31 |
-
* <p>If the Logging event level is within the specified range, then if
|
32 |
-
* <b><var>AcceptOnMatch</var></b> is <i>true</i>,
|
33 |
-
* {@link LoggerFilter::ACCEPT} is returned, and if
|
34 |
-
* <b><var>AcceptOnMatch</var></b> is <i>false</i>,
|
35 |
-
* {@link LoggerFilter::NEUTRAL} is returned.</p>
|
36 |
-
*
|
37 |
-
* <p>If <b><var>LevelMin</var></b> is not defined, then there is no
|
38 |
-
* minimum acceptable level (i.e. a level is never rejected for
|
39 |
-
* being too "low"/unimportant). If <b><var>LevelMax</var></b> is not
|
40 |
-
* defined, then there is no maximum acceptable level (ie a
|
41 |
-
* level is never rejected for being too "high"/important).</p>
|
42 |
-
*
|
43 |
-
* <p>Refer to the {@link LoggerAppender::setThreshold()} method
|
44 |
-
* available to <b>all</b> appenders extending {@link LoggerAppender}
|
45 |
-
* for a more convenient way to filter out events by level.</p>
|
46 |
-
*
|
47 |
-
* <p>
|
48 |
-
* An example for this filter:
|
49 |
-
*
|
50 |
-
* {@example ../../examples/php/filter_levelrange.php 19}
|
51 |
-
*
|
52 |
-
* <p>
|
53 |
-
* The corresponding XML file:
|
54 |
-
*
|
55 |
-
* {@example ../../examples/resources/filter_levelrange.xml 18}
|
56 |
-
*
|
57 |
-
* @author Simon Kitching
|
58 |
-
* @author based on the org.apache.log4j.varia.LevelRangeFilte Java code by Ceki Gülcü
|
59 |
-
*
|
60 |
-
* @version $Revision: 1213283 $
|
61 |
-
* @package log4php
|
62 |
-
* @subpackage filters
|
63 |
-
* @since 0.6
|
64 |
-
*/
|
65 |
-
class LoggerFilterLevelRange extends LoggerFilter {
|
66 |
-
|
67 |
-
/**
|
68 |
-
* @var boolean
|
69 |
-
*/
|
70 |
-
protected $acceptOnMatch = true;
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @var LoggerLevel
|
74 |
-
*/
|
75 |
-
protected $levelMin;
|
76 |
-
|
77 |
-
/**
|
78 |
-
* @var LoggerLevel
|
79 |
-
*/
|
80 |
-
protected $levelMax;
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @param boolean $acceptOnMatch
|
84 |
-
*/
|
85 |
-
public function setAcceptOnMatch($acceptOnMatch) {
|
86 |
-
$this->setBoolean('acceptOnMatch', $acceptOnMatch);
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* @param string $l the level min to match
|
91 |
-
*/
|
92 |
-
public function setLevelMin($level) {
|
93 |
-
$this->setLevel('levelMin', $level);
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* @param string $l the level max to match
|
98 |
-
*/
|
99 |
-
public function setLevelMax($level) {
|
100 |
-
$this->setLevel('levelMax', $level);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Return the decision of this filter.
|
105 |
-
*
|
106 |
-
* @param LoggerLoggingEvent $event
|
107 |
-
* @return integer
|
108 |
-
*/
|
109 |
-
public function decide(LoggerLoggingEvent $event) {
|
110 |
-
$level = $event->getLevel();
|
111 |
-
|
112 |
-
if($this->levelMin !== null) {
|
113 |
-
if($level->isGreaterOrEqual($this->levelMin) == false) {
|
114 |
-
// level of event is less than minimum
|
115 |
-
return LoggerFilter::DENY;
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
if($this->levelMax !== null) {
|
120 |
-
if($level->toInt() > $this->levelMax->toInt()) {
|
121 |
-
// level of event is greater than maximum
|
122 |
-
// Alas, there is no Level.isGreater method. and using
|
123 |
-
// a combo of isGreaterOrEqual && !Equal seems worse than
|
124 |
-
// checking the int values of the level objects..
|
125 |
-
return LoggerFilter::DENY;
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
if($this->acceptOnMatch) {
|
130 |
-
// this filter set up to bypass later filters and always return
|
131 |
-
// accept if level in range
|
132 |
-
return LoggerFilter::ACCEPT;
|
133 |
-
} else {
|
134 |
-
// event is ok for this filter; allow later filters to have a look..
|
135 |
-
return LoggerFilter::NEUTRAL;
|
136 |
-
}
|
137 |
-
}
|
138 |
-
}
|
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 |
+
/**
|
22 |
+
* This is a very simple filter based on level matching, which can be
|
23 |
+
* used to reject messages with priorities outside a certain range.
|
24 |
+
*
|
25 |
+
* <p>The filter admits three options <b><var>LevelMin</var></b>, <b><var>LevelMax</var></b>
|
26 |
+
* and <b><var>AcceptOnMatch</var></b>.</p>
|
27 |
+
*
|
28 |
+
* <p>If the level of the {@link LoggerLoggingEvent} is not between Min and Max
|
29 |
+
* (inclusive), then {@link LoggerFilter::DENY} is returned.</p>
|
30 |
+
*
|
31 |
+
* <p>If the Logging event level is within the specified range, then if
|
32 |
+
* <b><var>AcceptOnMatch</var></b> is <i>true</i>,
|
33 |
+
* {@link LoggerFilter::ACCEPT} is returned, and if
|
34 |
+
* <b><var>AcceptOnMatch</var></b> is <i>false</i>,
|
35 |
+
* {@link LoggerFilter::NEUTRAL} is returned.</p>
|
36 |
+
*
|
37 |
+
* <p>If <b><var>LevelMin</var></b> is not defined, then there is no
|
38 |
+
* minimum acceptable level (i.e. a level is never rejected for
|
39 |
+
* being too "low"/unimportant). If <b><var>LevelMax</var></b> is not
|
40 |
+
* defined, then there is no maximum acceptable level (ie a
|
41 |
+
* level is never rejected for being too "high"/important).</p>
|
42 |
+
*
|
43 |
+
* <p>Refer to the {@link LoggerAppender::setThreshold()} method
|
44 |
+
* available to <b>all</b> appenders extending {@link LoggerAppender}
|
45 |
+
* for a more convenient way to filter out events by level.</p>
|
46 |
+
*
|
47 |
+
* <p>
|
48 |
+
* An example for this filter:
|
49 |
+
*
|
50 |
+
* {@example ../../examples/php/filter_levelrange.php 19}
|
51 |
+
*
|
52 |
+
* <p>
|
53 |
+
* The corresponding XML file:
|
54 |
+
*
|
55 |
+
* {@example ../../examples/resources/filter_levelrange.xml 18}
|
56 |
+
*
|
57 |
+
* @author Simon Kitching
|
58 |
+
* @author based on the org.apache.log4j.varia.LevelRangeFilte Java code by Ceki Gülcü
|
59 |
+
*
|
60 |
+
* @version $Revision: 1213283 $
|
61 |
+
* @package log4php
|
62 |
+
* @subpackage filters
|
63 |
+
* @since 0.6
|
64 |
+
*/
|
65 |
+
class LoggerFilterLevelRange extends LoggerFilter {
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @var boolean
|
69 |
+
*/
|
70 |
+
protected $acceptOnMatch = true;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @var LoggerLevel
|
74 |
+
*/
|
75 |
+
protected $levelMin;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @var LoggerLevel
|
79 |
+
*/
|
80 |
+
protected $levelMax;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @param boolean $acceptOnMatch
|
84 |
+
*/
|
85 |
+
public function setAcceptOnMatch($acceptOnMatch) {
|
86 |
+
$this->setBoolean('acceptOnMatch', $acceptOnMatch);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @param string $l the level min to match
|
91 |
+
*/
|
92 |
+
public function setLevelMin($level) {
|
93 |
+
$this->setLevel('levelMin', $level);
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @param string $l the level max to match
|
98 |
+
*/
|
99 |
+
public function setLevelMax($level) {
|
100 |
+
$this->setLevel('levelMax', $level);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Return the decision of this filter.
|
105 |
+
*
|
106 |
+
* @param LoggerLoggingEvent $event
|
107 |
+
* @return integer
|
108 |
+
*/
|
109 |
+
public function decide(LoggerLoggingEvent $event) {
|
110 |
+
$level = $event->getLevel();
|
111 |
+
|
112 |
+
if($this->levelMin !== null) {
|
113 |
+
if($level->isGreaterOrEqual($this->levelMin) == false) {
|
114 |
+
// level of event is less than minimum
|
115 |
+
return LoggerFilter::DENY;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
if($this->levelMax !== null) {
|
120 |
+
if($level->toInt() > $this->levelMax->toInt()) {
|
121 |
+
// level of event is greater than maximum
|
122 |
+
// Alas, there is no Level.isGreater method. and using
|
123 |
+
// a combo of isGreaterOrEqual && !Equal seems worse than
|
124 |
+
// checking the int values of the level objects..
|
125 |
+
return LoggerFilter::DENY;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
if($this->acceptOnMatch) {
|
130 |
+
// this filter set up to bypass later filters and always return
|
131 |
+
// accept if level in range
|
132 |
+
return LoggerFilter::ACCEPT;
|
133 |
+
} else {
|
134 |
+
// event is ok for this filter; allow later filters to have a look..
|
135 |
+
return LoggerFilter::NEUTRAL;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/filters/LoggerFilterStringMatch.php
RENAMED
@@ -1,89 +1,89 @@
|
|
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 |
-
/**
|
22 |
-
* This is a very simple filter based on string matching.
|
23 |
-
*
|
24 |
-
* <p>The filter admits two options {@link $stringToMatch} and
|
25 |
-
* {@link $acceptOnMatch}. If there is a match (using {@link PHP_MANUAL#strpos}
|
26 |
-
* between the value of the {@link $stringToMatch} option and the message
|
27 |
-
* of the {@link LoggerLoggingEvent},
|
28 |
-
* then the {@link decide()} method returns {@link LoggerFilter::ACCEPT} if
|
29 |
-
* the <b>AcceptOnMatch</b> option value is true, if it is false then
|
30 |
-
* {@link LoggerFilter::DENY} is returned. If there is no match, {@link LoggerFilter::NEUTRAL}
|
31 |
-
* is returned.</p>
|
32 |
-
*
|
33 |
-
* <p>
|
34 |
-
* An example for this filter:
|
35 |
-
*
|
36 |
-
* {@example ../../examples/php/filter_stringmatch.php 19}
|
37 |
-
*
|
38 |
-
* <p>
|
39 |
-
* The corresponding XML file:
|
40 |
-
*
|
41 |
-
* {@example ../../examples/resources/filter_stringmatch.xml 18}
|
42 |
-
*
|
43 |
-
* @version $Revision: 1213283 $
|
44 |
-
* @package log4php
|
45 |
-
* @subpackage filters
|
46 |
-
* @since 0.3
|
47 |
-
*/
|
48 |
-
class LoggerFilterStringMatch extends LoggerFilter {
|
49 |
-
|
50 |
-
/**
|
51 |
-
* @var boolean
|
52 |
-
*/
|
53 |
-
protected $acceptOnMatch = true;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @var string
|
57 |
-
*/
|
58 |
-
protected $stringToMatch;
|
59 |
-
|
60 |
-
/**
|
61 |
-
* @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
|
62 |
-
*/
|
63 |
-
public function setAcceptOnMatch($acceptOnMatch) {
|
64 |
-
$this->setBoolean('acceptOnMatch', $acceptOnMatch);
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* @param string $s the string to match
|
69 |
-
*/
|
70 |
-
public function setStringToMatch($string) {
|
71 |
-
$this->setString('stringToMatch', $string);
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
|
76 |
-
*/
|
77 |
-
public function decide(LoggerLoggingEvent $event) {
|
78 |
-
$msg = $event->getRenderedMessage();
|
79 |
-
|
80 |
-
if($msg === null or $this->stringToMatch === null) {
|
81 |
-
return LoggerFilter::NEUTRAL;
|
82 |
-
}
|
83 |
-
|
84 |
-
if(strpos($msg, $this->stringToMatch) !== false ) {
|
85 |
-
return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
|
86 |
-
}
|
87 |
-
return LoggerFilter::NEUTRAL;
|
88 |
-
}
|
89 |
-
}
|
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 |
+
/**
|
22 |
+
* This is a very simple filter based on string matching.
|
23 |
+
*
|
24 |
+
* <p>The filter admits two options {@link $stringToMatch} and
|
25 |
+
* {@link $acceptOnMatch}. If there is a match (using {@link PHP_MANUAL#strpos}
|
26 |
+
* between the value of the {@link $stringToMatch} option and the message
|
27 |
+
* of the {@link LoggerLoggingEvent},
|
28 |
+
* then the {@link decide()} method returns {@link LoggerFilter::ACCEPT} if
|
29 |
+
* the <b>AcceptOnMatch</b> option value is true, if it is false then
|
30 |
+
* {@link LoggerFilter::DENY} is returned. If there is no match, {@link LoggerFilter::NEUTRAL}
|
31 |
+
* is returned.</p>
|
32 |
+
*
|
33 |
+
* <p>
|
34 |
+
* An example for this filter:
|
35 |
+
*
|
36 |
+
* {@example ../../examples/php/filter_stringmatch.php 19}
|
37 |
+
*
|
38 |
+
* <p>
|
39 |
+
* The corresponding XML file:
|
40 |
+
*
|
41 |
+
* {@example ../../examples/resources/filter_stringmatch.xml 18}
|
42 |
+
*
|
43 |
+
* @version $Revision: 1213283 $
|
44 |
+
* @package log4php
|
45 |
+
* @subpackage filters
|
46 |
+
* @since 0.3
|
47 |
+
*/
|
48 |
+
class LoggerFilterStringMatch extends LoggerFilter {
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @var boolean
|
52 |
+
*/
|
53 |
+
protected $acceptOnMatch = true;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @var string
|
57 |
+
*/
|
58 |
+
protected $stringToMatch;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
|
62 |
+
*/
|
63 |
+
public function setAcceptOnMatch($acceptOnMatch) {
|
64 |
+
$this->setBoolean('acceptOnMatch', $acceptOnMatch);
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @param string $s the string to match
|
69 |
+
*/
|
70 |
+
public function setStringToMatch($string) {
|
71 |
+
$this->setString('stringToMatch', $string);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
|
76 |
+
*/
|
77 |
+
public function decide(LoggerLoggingEvent $event) {
|
78 |
+
$msg = $event->getRenderedMessage();
|
79 |
+
|
80 |
+
if($msg === null or $this->stringToMatch === null) {
|
81 |
+
return LoggerFilter::NEUTRAL;
|
82 |
+
}
|
83 |
+
|
84 |
+
if(strpos($msg, $this->stringToMatch) !== false ) {
|
85 |
+
return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY;
|
86 |
+
}
|
87 |
+
return LoggerFilter::NEUTRAL;
|
88 |
+
}
|
89 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/helpers/LoggerFormattingInfo.php
RENAMED
@@ -1,50 +1,54 @@
|
|
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 |
-
/**
|
22 |
-
* This class encapsulates the information obtained when parsing
|
23 |
-
* formatting modifiers in conversion modifiers.
|
24 |
-
*
|
25 |
-
* @package log4php
|
26 |
-
* @subpackage helpers
|
27 |
-
* @since 0.3
|
28 |
-
*/
|
29 |
-
class LoggerFormattingInfo {
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* This class encapsulates the information obtained when parsing
|
23 |
+
* formatting modifiers in conversion modifiers.
|
24 |
+
*
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage helpers
|
27 |
+
* @since 0.3
|
28 |
+
*/
|
29 |
+
class LoggerFormattingInfo {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Minimal output length. If output is shorter than this value, it will be
|
33 |
+
* padded with spaces.
|
34 |
+
*/
|
35 |
+
public $min = 0;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Maximum output length. If output is longer than this value, it will be
|
39 |
+
* trimmed.
|
40 |
+
*/
|
41 |
+
public $max = PHP_INT_MAX;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Whether to pad the string from the left. If set to false, the string
|
45 |
+
* will be padded from the right.
|
46 |
+
*/
|
47 |
+
public $padLeft = true;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Whether to trim the string from the left. If set to false, the string
|
51 |
+
* will be trimmed from the right.
|
52 |
+
*/
|
53 |
+
public $trimLeft = false;
|
54 |
+
}
|
lib/Log4php/helpers/LoggerOptionConverter.php
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* A convenience class to convert property values to specific types.
|
23 |
+
*
|
24 |
+
* @version $Revision: 1374617 $
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage helpers
|
27 |
+
* @since 0.5
|
28 |
+
*/
|
29 |
+
class LoggerOptionConverter {
|
30 |
+
|
31 |
+
/** String values which are converted to boolean TRUE. */
|
32 |
+
private static $trueValues = array('1', 'true', 'yes', 'on');
|
33 |
+
|
34 |
+
/**
|
35 |
+
* String values which are converted to boolean FALSE.
|
36 |
+
*
|
37 |
+
* Note that an empty string must convert to false, because
|
38 |
+
* parse_ini_file() which is used for parsing configuration
|
39 |
+
* converts the value _false_ to an empty string.
|
40 |
+
*/
|
41 |
+
private static $falseValues = array('0', 'false', 'no', 'off', '');
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Read a predefined var.
|
45 |
+
*
|
46 |
+
* It returns a value referenced by <var>$key</var> using this search criteria:
|
47 |
+
* - if <var>$key</var> is a constant then return it. Else
|
48 |
+
* - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
|
49 |
+
* - return <var>$def</var>.
|
50 |
+
*
|
51 |
+
* @param string $key The key to search for.
|
52 |
+
* @param string $def The default value to return.
|
53 |
+
* @return string the string value of the system property, or the default
|
54 |
+
* value if there is no property with that key.
|
55 |
+
*/
|
56 |
+
public static function getSystemProperty($key, $def) {
|
57 |
+
if(defined($key)) {
|
58 |
+
return (string)constant($key);
|
59 |
+
} else if(isset($_SERVER[$key])) {
|
60 |
+
return (string)$_SERVER[$key];
|
61 |
+
} else if(isset($_ENV[$key])) {
|
62 |
+
return (string)$_ENV[$key];
|
63 |
+
} else {
|
64 |
+
return $def;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
/** Converts $value to boolean, or throws an exception if not possible. */
|
69 |
+
public static function toBooleanEx($value) {
|
70 |
+
if (isset($value)) {
|
71 |
+
if (is_bool($value)) {
|
72 |
+
return $value;
|
73 |
+
}
|
74 |
+
$value = strtolower(trim($value));
|
75 |
+
if (in_array($value, self::$trueValues)) {
|
76 |
+
return true;
|
77 |
+
}
|
78 |
+
if (in_array($value, self::$falseValues)) {
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Converts $value to integer, or throws an exception if not possible.
|
88 |
+
* Floats cannot be converted to integer.
|
89 |
+
*/
|
90 |
+
public static function toIntegerEx($value) {
|
91 |
+
if (is_integer($value)) {
|
92 |
+
return $value;
|
93 |
+
}
|
94 |
+
if (is_numeric($value) && ($value == (integer) $value)) {
|
95 |
+
return (integer) $value;
|
96 |
+
}
|
97 |
+
|
98 |
+
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Converts $value to integer, or throws an exception if not possible.
|
103 |
+
* Floats cannot be converted to integer.
|
104 |
+
*/
|
105 |
+
public static function toPositiveIntegerEx($value) {
|
106 |
+
if (is_integer($value) && $value > 0) {
|
107 |
+
return $value;
|
108 |
+
}
|
109 |
+
if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
|
110 |
+
return (integer) $value;
|
111 |
+
}
|
112 |
+
|
113 |
+
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
|
114 |
+
}
|
115 |
+
|
116 |
+
/** Converts the value to a level. Throws an exception if not possible. */
|
117 |
+
public static function toLevelEx($value) {
|
118 |
+
if ($value instanceof LoggerLevel) {
|
119 |
+
return $value;
|
120 |
+
}
|
121 |
+
$level = LoggerLevel::toLevel($value);
|
122 |
+
if ($level === null) {
|
123 |
+
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a logger level.");
|
124 |
+
}
|
125 |
+
return $level;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Converts a value to a valid file size (integer).
|
130 |
+
*
|
131 |
+
* Supports 'KB', 'MB' and 'GB' suffixes, where KB = 1024 B etc.
|
132 |
+
*
|
133 |
+
* The final value will be rounded to the nearest integer.
|
134 |
+
*
|
135 |
+
* Examples:
|
136 |
+
* - '100' => 100
|
137 |
+
* - '100.12' => 100
|
138 |
+
* - '100KB' => 102400
|
139 |
+
* - '1.5MB' => 1572864
|
140 |
+
*
|
141 |
+
* @param mixed $value File size (optionally with suffix).
|
142 |
+
* @return integer Parsed file size.
|
143 |
+
*/
|
144 |
+
public static function toFileSizeEx($value) {
|
145 |
+
|
146 |
+
if (empty($value)) {
|
147 |
+
throw new LoggerException("Empty value cannot be converted to a file size.");
|
148 |
+
}
|
149 |
+
|
150 |
+
if (is_numeric($value)) {
|
151 |
+
return (integer) $value;
|
152 |
+
}
|
153 |
+
|
154 |
+
if (!is_string($value)) {
|
155 |
+
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a file size.");
|
156 |
+
}
|
157 |
+
|
158 |
+
$str = strtoupper(trim($value));
|
159 |
+
$count = preg_match('/^([0-9.]+)(KB|MB|GB)?$/', $str, $matches);
|
160 |
+
|
161 |
+
if ($count > 0) {
|
162 |
+
$size = $matches[1];
|
163 |
+
$unit = $matches[2];
|
164 |
+
|
165 |
+
switch($unit) {
|
166 |
+
case 'KB': $size *= pow(1024, 1); break;
|
167 |
+
case 'MB': $size *= pow(1024, 2); break;
|
168 |
+
case 'GB': $size *= pow(1024, 3); break;
|
169 |
+
}
|
170 |
+
|
171 |
+
return (integer) $size;
|
172 |
+
}
|
173 |
+
|
174 |
+
throw new LoggerException("Given value [$value] cannot be converted to a file size.");
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Converts a value to string, or throws an exception if not possible.
|
179 |
+
*
|
180 |
+
* Objects can be converted to string if they implement the magic
|
181 |
+
* __toString() method.
|
182 |
+
*
|
183 |
+
*/
|
184 |
+
public static function toStringEx($value) {
|
185 |
+
if (is_string($value)) {
|
186 |
+
return $value;
|
187 |
+
}
|
188 |
+
if (is_numeric($value)) {
|
189 |
+
return (string) $value;
|
190 |
+
}
|
191 |
+
if (is_object($value) && method_exists($value, '__toString')) {
|
192 |
+
return (string) $value;
|
193 |
+
}
|
194 |
+
|
195 |
+
throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Performs value substitution for string options.
|
200 |
+
*
|
201 |
+
* An option can contain PHP constants delimited by '${' and '}'.
|
202 |
+
*
|
203 |
+
* E.g. for input string "some ${FOO} value", the method will attempt
|
204 |
+
* to substitute ${FOO} with the value of constant FOO if it exists.
|
205 |
+
*
|
206 |
+
* Therefore, if FOO is a constant, and it has value "bar", the resulting
|
207 |
+
* string will be "some bar value".
|
208 |
+
*
|
209 |
+
* If the constant is not defined, it will be replaced by an empty string,
|
210 |
+
* and the resulting string will be "some value".
|
211 |
+
*
|
212 |
+
* @param string $string String on which to perform substitution.
|
213 |
+
* @return string
|
214 |
+
*/
|
215 |
+
public static function substConstants($string) {
|
216 |
+
preg_match_all('/\${([^}]+)}/', $string, $matches);
|
217 |
+
|
218 |
+
foreach($matches[1] as $key => $match) {
|
219 |
+
$match = trim($match);
|
220 |
+
$search = $matches[0][$key];
|
221 |
+
$replacement = defined($match) ? constant($match) : '';
|
222 |
+
$string = str_replace($search, $replacement, $string);
|
223 |
+
}
|
224 |
+
return $string;
|
225 |
+
}
|
226 |
+
}
|
lib/Log4php/helpers/LoggerPatternParser.php
ADDED
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Most of the work of the {@link LoggerPatternLayout} class
|
23 |
+
* is delegated to the {@link LoggerPatternParser} class.
|
24 |
+
*
|
25 |
+
* <p>It is this class that parses conversion patterns and creates
|
26 |
+
* a chained list of {@link LoggerPatternConverter} converters.</p>
|
27 |
+
*
|
28 |
+
* @version $Revision: 1395467 $
|
29 |
+
* @package log4php
|
30 |
+
* @subpackage helpers
|
31 |
+
*
|
32 |
+
* @since 0.3
|
33 |
+
*/
|
34 |
+
class LoggerPatternParser {
|
35 |
+
|
36 |
+
/** Escape character for conversion words in the conversion pattern. */
|
37 |
+
const ESCAPE_CHAR = '%';
|
38 |
+
|
39 |
+
/** Maps conversion words to relevant converters. */
|
40 |
+
private $converterMap;
|
41 |
+
|
42 |
+
/** Conversion pattern used in layout. */
|
43 |
+
private $pattern;
|
44 |
+
|
45 |
+
/** Regex pattern used for parsing the conversion pattern. */
|
46 |
+
private $regex;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* First converter in the chain.
|
50 |
+
* @var LoggerPatternConverter
|
51 |
+
*/
|
52 |
+
private $head;
|
53 |
+
|
54 |
+
/** Last converter in the chain. */
|
55 |
+
private $tail;
|
56 |
+
|
57 |
+
public function __construct($pattern, $converterMap) {
|
58 |
+
$this->pattern = $pattern;
|
59 |
+
$this->converterMap = $converterMap;
|
60 |
+
|
61 |
+
// Construct the regex pattern
|
62 |
+
$this->regex =
|
63 |
+
'/' . // Starting regex pattern delimiter
|
64 |
+
self::ESCAPE_CHAR . // Character which marks the start of the conversion pattern
|
65 |
+
'(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional)
|
66 |
+
'(?P<word>[a-zA-Z]+)' . // The conversion word
|
67 |
+
'(?P<option>{[^}]*})?' . // Conversion option in braces (optional)
|
68 |
+
'/'; // Ending regex pattern delimiter
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Parses the conversion pattern string, converts it to a chain of pattern
|
73 |
+
* converters and returns the first converter in the chain.
|
74 |
+
*
|
75 |
+
* @return LoggerPatternConverter
|
76 |
+
*/
|
77 |
+
public function parse() {
|
78 |
+
|
79 |
+
// Skip parsing if the pattern is empty
|
80 |
+
if (empty($this->pattern)) {
|
81 |
+
$this->addLiteral('');
|
82 |
+
return $this->head;
|
83 |
+
}
|
84 |
+
|
85 |
+
// Find all conversion words in the conversion pattern
|
86 |
+
$count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE);
|
87 |
+
if ($count === false) {
|
88 |
+
$error = error_get_last();
|
89 |
+
throw new LoggerException("Failed parsing layotut pattern: {$error['message']}");
|
90 |
+
}
|
91 |
+
|
92 |
+
$prevEnd = 0;
|
93 |
+
|
94 |
+
foreach($matches[0] as $key => $item) {
|
95 |
+
|
96 |
+
// Locate where the conversion command starts and ends
|
97 |
+
$length = strlen($item[0]);
|
98 |
+
$start = $item[1];
|
99 |
+
$end = $item[1] + $length;
|
100 |
+
|
101 |
+
// Find any literal expressions between matched commands
|
102 |
+
if ($start > $prevEnd) {
|
103 |
+
$literal = substr($this->pattern, $prevEnd, $start - $prevEnd);
|
104 |
+
$this->addLiteral($literal);
|
105 |
+
}
|
106 |
+
|
107 |
+
// Extract the data from the matched command
|
108 |
+
$word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null;
|
109 |
+
$modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null;
|
110 |
+
$option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null;
|
111 |
+
|
112 |
+
// Create a converter and add it to the chain
|
113 |
+
$this->addConverter($word, $modifiers, $option);
|
114 |
+
|
115 |
+
$prevEnd = $end;
|
116 |
+
}
|
117 |
+
|
118 |
+
// Add any trailing literals
|
119 |
+
if ($end < strlen($this->pattern)) {
|
120 |
+
$literal = substr($this->pattern, $end);
|
121 |
+
$this->addLiteral($literal);
|
122 |
+
}
|
123 |
+
|
124 |
+
return $this->head;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Adds a literal converter to the converter chain.
|
129 |
+
* @param string $string The string for the literal converter.
|
130 |
+
*/
|
131 |
+
private function addLiteral($string) {
|
132 |
+
$converter = new LoggerPatternConverterLiteral($string);
|
133 |
+
$this->addToChain($converter);
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Adds a non-literal converter to the converter chain.
|
138 |
+
*
|
139 |
+
* @param string $word The conversion word, used to determine which
|
140 |
+
* converter will be used.
|
141 |
+
* @param string $modifiers Formatting modifiers.
|
142 |
+
* @param string $option Option to pass to the converter.
|
143 |
+
*/
|
144 |
+
private function addConverter($word, $modifiers, $option) {
|
145 |
+
$formattingInfo = $this->parseModifiers($modifiers);
|
146 |
+
$option = trim($option, "{} ");
|
147 |
+
|
148 |
+
if (isset($this->converterMap[$word])) {
|
149 |
+
$converter = $this->getConverter($word, $formattingInfo, $option);
|
150 |
+
$this->addToChain($converter);
|
151 |
+
} else {
|
152 |
+
trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Determines which converter to use based on the conversion word. Creates
|
158 |
+
* an instance of the converter using the provided formatting info and
|
159 |
+
* option and returns it.
|
160 |
+
*
|
161 |
+
* @param string $word The conversion word.
|
162 |
+
* @param LoggerFormattingInfo $info Formatting info.
|
163 |
+
* @param string $option Converter option.
|
164 |
+
*
|
165 |
+
* @throws LoggerException
|
166 |
+
*
|
167 |
+
* @return LoggerPatternConverter
|
168 |
+
*/
|
169 |
+
private function getConverter($word, $info, $option) {
|
170 |
+
if (!isset($this->converterMap[$word])) {
|
171 |
+
throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword.");
|
172 |
+
}
|
173 |
+
|
174 |
+
$converterClass = $this->converterMap[$word];
|
175 |
+
if(!class_exists($converterClass)) {
|
176 |
+
throw new LoggerException("Class '$converterClass' does not exist.");
|
177 |
+
}
|
178 |
+
|
179 |
+
$converter = new $converterClass($info, $option);
|
180 |
+
if(!($converter instanceof LoggerPatternConverter)) {
|
181 |
+
throw new LoggerException("Class '$converterClass' is not an instance of LoggerPatternConverter.");
|
182 |
+
}
|
183 |
+
|
184 |
+
return $converter;
|
185 |
+
}
|
186 |
+
|
187 |
+
/** Adds a converter to the chain and updates $head and $tail pointers. */
|
188 |
+
private function addToChain(LoggerPatternConverter $converter) {
|
189 |
+
if (!isset($this->head)) {
|
190 |
+
$this->head = $converter;
|
191 |
+
$this->tail = $this->head;
|
192 |
+
} else {
|
193 |
+
$this->tail->next = $converter;
|
194 |
+
$this->tail = $this->tail->next;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Parses the formatting modifiers and produces the corresponding
|
200 |
+
* LoggerFormattingInfo object.
|
201 |
+
*
|
202 |
+
* @param string $modifier
|
203 |
+
* @return LoggerFormattingInfo
|
204 |
+
* @throws LoggerException
|
205 |
+
*/
|
206 |
+
private function parseModifiers($modifiers) {
|
207 |
+
$info = new LoggerFormattingInfo();
|
208 |
+
|
209 |
+
// If no modifiers are given, return default values
|
210 |
+
if (empty($modifiers)) {
|
211 |
+
return $info;
|
212 |
+
}
|
213 |
+
|
214 |
+
// Validate
|
215 |
+
$pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
|
216 |
+
if (!preg_match($pattern, $modifiers)) {
|
217 |
+
trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
|
218 |
+
return $info;
|
219 |
+
}
|
220 |
+
|
221 |
+
$parts = explode('.', $modifiers);
|
222 |
+
|
223 |
+
if (!empty($parts[0])) {
|
224 |
+
$minPart = (integer) $parts[0];
|
225 |
+
$info->min = abs($minPart);
|
226 |
+
$info->padLeft = ($minPart > 0);
|
227 |
+
}
|
228 |
+
|
229 |
+
if (!empty($parts[1])) {
|
230 |
+
$maxPart = (integer) $parts[1];
|
231 |
+
$info->max = abs($maxPart);
|
232 |
+
$info->trimLeft = ($maxPart < 0);
|
233 |
+
}
|
234 |
+
|
235 |
+
return $info;
|
236 |
+
}
|
237 |
+
}
|
lib/Log4php/helpers/LoggerUtils.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Contains various helper methods.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage helpers
|
26 |
+
* @since 2.3
|
27 |
+
*/
|
28 |
+
class LoggerUtils {
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Splits a fully qualified class name into fragments delimited by the
|
32 |
+
* namespace separator (\).
|
33 |
+
*
|
34 |
+
* For backward compatibility, a dot (.) can be used as a delimiter as
|
35 |
+
* well.
|
36 |
+
*
|
37 |
+
* @param string $name
|
38 |
+
*
|
39 |
+
* @return array Class name split into fragments.
|
40 |
+
*/
|
41 |
+
public static function tokenizeClassName($name) {
|
42 |
+
$name = str_replace('.', '\\', $name);
|
43 |
+
$name = trim($name, ' \\');
|
44 |
+
$fragments = explode('\\', $name);
|
45 |
+
|
46 |
+
foreach($fragments as $key => $fragment) {
|
47 |
+
if (trim($fragment) === '') {
|
48 |
+
unset($fragments[$key]);
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
return $fragments;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Attempts to shorten the given class name to the desired length.
|
57 |
+
*
|
58 |
+
* This is done by separating the class name into fragments (delimited
|
59 |
+
* by \ or .) and trimming individual fragments, starting with the left,
|
60 |
+
* until desired length has been reached.
|
61 |
+
*
|
62 |
+
* The final fragment (i.e. class name) will never be shortened so the
|
63 |
+
* result may still be longer than given length.
|
64 |
+
*
|
65 |
+
* @param string $name The (qualified) class name.
|
66 |
+
* @param integer $length The length to shorten to. If null or 0 is given,
|
67 |
+
* the name will be returned without shortening.
|
68 |
+
*/
|
69 |
+
public static function shortenClassName($name, $length) {
|
70 |
+
if ($length === null || $length < 0) {
|
71 |
+
return $name;
|
72 |
+
}
|
73 |
+
|
74 |
+
$name = str_replace('.', '\\', $name);
|
75 |
+
$name = trim($name, ' \\');
|
76 |
+
|
77 |
+
// Check if any shortening is required
|
78 |
+
$currentLength = strlen($name);
|
79 |
+
if ($currentLength <= $length) {
|
80 |
+
return $name;
|
81 |
+
}
|
82 |
+
|
83 |
+
// Split name into fragments
|
84 |
+
$fragments = explode('\\', $name);
|
85 |
+
|
86 |
+
// If zero length is specified, return only last fragment
|
87 |
+
if ($length == 0) {
|
88 |
+
return array_pop($fragments);
|
89 |
+
}
|
90 |
+
|
91 |
+
// If the name splits to only one fragment, then it cannot be shortened
|
92 |
+
$count = count($fragments);
|
93 |
+
if ($count == 1) {
|
94 |
+
return $name;
|
95 |
+
}
|
96 |
+
|
97 |
+
foreach($fragments as $key => &$fragment) {
|
98 |
+
|
99 |
+
// Never shorten last fragment
|
100 |
+
if ($key == $count - 1) {
|
101 |
+
break;
|
102 |
+
}
|
103 |
+
|
104 |
+
// Check for empty fragments (shouldn't happen but it's possible)
|
105 |
+
$fragLen = strlen($fragment);
|
106 |
+
if ($fragLen <= 1) {
|
107 |
+
continue;
|
108 |
+
}
|
109 |
+
|
110 |
+
// Shorten fragment to one character and check if total length satisfactory
|
111 |
+
$fragment = substr($fragment, 0, 1);
|
112 |
+
$currentLength = $currentLength - $fragLen + 1;
|
113 |
+
|
114 |
+
if ($currentLength <= $length) {
|
115 |
+
break;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
unset($fragment);
|
119 |
+
|
120 |
+
return implode('\\', $fragments);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutHtml.php
RENAMED
@@ -1,214 +1,214 @@
|
|
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 |
-
/**
|
22 |
-
* This layout outputs events in a HTML table.
|
23 |
-
*
|
24 |
-
* Configurable parameters for this layout are:
|
25 |
-
*
|
26 |
-
* - title
|
27 |
-
* - locationInfo
|
28 |
-
*
|
29 |
-
* An example for this layout:
|
30 |
-
*
|
31 |
-
* {@example ../../examples/php/layout_html.php 19}<br>
|
32 |
-
*
|
33 |
-
* The corresponding XML file:
|
34 |
-
*
|
35 |
-
* {@example ../../examples/resources/layout_html.properties 18}
|
36 |
-
*
|
37 |
-
* The above will print a HTML table that looks, converted back to plain text, like the following:<br>
|
38 |
-
* <pre>
|
39 |
-
* Log session start time Wed Sep 9 00:11:30 2009
|
40 |
-
*
|
41 |
-
* Time Thread Level Category Message
|
42 |
-
* 0 8318 INFO root Hello World!
|
43 |
-
* </pre>
|
44 |
-
*
|
45 |
-
* @version $Revision:
|
46 |
-
* @package log4php
|
47 |
-
* @subpackage layouts
|
48 |
-
*/
|
49 |
-
class LoggerLayoutHtml extends LoggerLayout {
|
50 |
-
/**
|
51 |
-
* The <b>LocationInfo</b> option takes a boolean value. By
|
52 |
-
* default, it is set to false which means there will be no location
|
53 |
-
* information output by this layout. If the the option is set to
|
54 |
-
* true, then the file name and line number of the statement
|
55 |
-
* at the origin of the log statement will be output.
|
56 |
-
*
|
57 |
-
* <p>If you are embedding this layout within a {@link LoggerAppenderMail}
|
58 |
-
* or a {@link LoggerAppenderMailEvent} then make sure to set the
|
59 |
-
* <b>LocationInfo</b> option of that appender as well.
|
60 |
-
* @var boolean
|
61 |
-
*/
|
62 |
-
protected $locationInfo = false;
|
63 |
-
|
64 |
-
/**
|
65 |
-
* The <b>Title</b> option takes a String value. This option sets the
|
66 |
-
* document title of the generated HTML document.
|
67 |
-
* Defaults to 'Log4php Log Messages'.
|
68 |
-
* @var string
|
69 |
-
*/
|
70 |
-
protected $title = "Log4php Log Messages";
|
71 |
-
|
72 |
-
/**
|
73 |
-
* The <b>LocationInfo</b> option takes a boolean value. By
|
74 |
-
* default, it is set to false which means there will be no location
|
75 |
-
* information output by this layout. If the the option is set to
|
76 |
-
* true, then the file name and line number of the statement
|
77 |
-
* at the origin of the log statement will be output.
|
78 |
-
*
|
79 |
-
* <p>If you are embedding this layout within a {@link LoggerAppenderMail}
|
80 |
-
* or a {@link LoggerAppenderMailEvent} then make sure to set the
|
81 |
-
* <b>LocationInfo</b> option of that appender as well.
|
82 |
-
*/
|
83 |
-
public function setLocationInfo($flag) {
|
84 |
-
$this->setBoolean('locationInfo', $flag);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Returns the current value of the <b>LocationInfo</b> option.
|
89 |
-
*/
|
90 |
-
public function getLocationInfo() {
|
91 |
-
return $this->locationInfo;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* The <b>Title</b> option takes a String value. This option sets the
|
96 |
-
* document title of the generated HTML document.
|
97 |
-
* Defaults to 'Log4php Log Messages'.
|
98 |
-
*/
|
99 |
-
public function setTitle($title) {
|
100 |
-
$this->setString('title', $title);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* @return string Returns the current value of the <b>Title</b> option.
|
105 |
-
*/
|
106 |
-
public function getTitle() {
|
107 |
-
return $this->title;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @return string Returns the content type output by this layout, i.e "text/html".
|
112 |
-
*/
|
113 |
-
public function getContentType() {
|
114 |
-
return "text/html";
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* @param LoggerLoggingEvent $event
|
119 |
-
* @return string
|
120 |
-
*/
|
121 |
-
public function format(LoggerLoggingEvent $event) {
|
122 |
-
$sbuf = PHP_EOL . "<tr>" . PHP_EOL;
|
123 |
-
|
124 |
-
$sbuf .= "<td>";
|
125 |
-
$sbuf .= $event->
|
126 |
-
$sbuf .= "</td>" . PHP_EOL;
|
127 |
-
|
128 |
-
$sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
|
129 |
-
$sbuf .= $event->getThreadName();
|
130 |
-
$sbuf .= "</td>" . PHP_EOL;
|
131 |
-
|
132 |
-
$sbuf .= "<td title=\"Level\">";
|
133 |
-
|
134 |
-
$level = $event->getLevel();
|
135 |
-
|
136 |
-
if ($level->equals(LoggerLevel::getLevelDebug())) {
|
137 |
-
$sbuf .= "<font color=\"#339933\">$level</font>";
|
138 |
-
} else if ($level->equals(LoggerLevel::getLevelWarn())) {
|
139 |
-
$sbuf .= "<font color=\"#993300\"><strong>$level</strong></font>";
|
140 |
-
} else {
|
141 |
-
$sbuf .= $level;
|
142 |
-
}
|
143 |
-
$sbuf .= "</td>" . PHP_EOL;
|
144 |
-
|
145 |
-
$sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
|
146 |
-
$sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
|
147 |
-
$sbuf .= "</td>" . PHP_EOL;
|
148 |
-
|
149 |
-
if ($this->locationInfo) {
|
150 |
-
$locInfo = $event->getLocationInformation();
|
151 |
-
$sbuf .= "<td>";
|
152 |
-
$sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES). ':' . $locInfo->getLineNumber();
|
153 |
-
$sbuf .= "</td>" . PHP_EOL;
|
154 |
-
}
|
155 |
-
|
156 |
-
$sbuf .= "<td title=\"Message\">";
|
157 |
-
$sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
|
158 |
-
$sbuf .= "</td>" . PHP_EOL;
|
159 |
-
|
160 |
-
$sbuf .= "</tr>" . PHP_EOL;
|
161 |
-
|
162 |
-
if ($event->getNDC() != null) {
|
163 |
-
$sbuf .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">";
|
164 |
-
$sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
|
165 |
-
$sbuf .= "</td></tr>" . PHP_EOL;
|
166 |
-
}
|
167 |
-
return $sbuf;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* @return string Returns appropriate HTML headers.
|
172 |
-
*/
|
173 |
-
public function getHeader() {
|
174 |
-
$sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
|
175 |
-
$sbuf .= "<html>" . PHP_EOL;
|
176 |
-
$sbuf .= "<head>" . PHP_EOL;
|
177 |
-
$sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
|
178 |
-
$sbuf .= "<style type=\"text/css\">" . PHP_EOL;
|
179 |
-
$sbuf .= "<!--" . PHP_EOL;
|
180 |
-
$sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
|
181 |
-
$sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
|
182 |
-
$sbuf .= "-->" . PHP_EOL;
|
183 |
-
$sbuf .= "</style>" . PHP_EOL;
|
184 |
-
$sbuf .= "</head>" . PHP_EOL;
|
185 |
-
$sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
|
186 |
-
$sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
|
187 |
-
$sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
|
188 |
-
$sbuf .= "<br>" . PHP_EOL;
|
189 |
-
$sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
|
190 |
-
$sbuf .= "<tr>" . PHP_EOL;
|
191 |
-
$sbuf .= "<th>Time</th>" . PHP_EOL;
|
192 |
-
$sbuf .= "<th>Thread</th>" . PHP_EOL;
|
193 |
-
$sbuf .= "<th>Level</th>" . PHP_EOL;
|
194 |
-
$sbuf .= "<th>Category</th>" . PHP_EOL;
|
195 |
-
if ($this->locationInfo) {
|
196 |
-
$sbuf .= "<th>File:Line</th>" . PHP_EOL;
|
197 |
-
}
|
198 |
-
$sbuf .= "<th>Message</th>" . PHP_EOL;
|
199 |
-
$sbuf .= "</tr>" . PHP_EOL;
|
200 |
-
|
201 |
-
return $sbuf;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* @return string Returns the appropriate HTML footers.
|
206 |
-
*/
|
207 |
-
public function getFooter() {
|
208 |
-
$sbuf = "</table>" . PHP_EOL;
|
209 |
-
$sbuf .= "<br>" . PHP_EOL;
|
210 |
-
$sbuf .= "</body></html>";
|
211 |
-
|
212 |
-
return $sbuf;
|
213 |
-
}
|
214 |
-
}
|
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 |
+
/**
|
22 |
+
* This layout outputs events in a HTML table.
|
23 |
+
*
|
24 |
+
* Configurable parameters for this layout are:
|
25 |
+
*
|
26 |
+
* - title
|
27 |
+
* - locationInfo
|
28 |
+
*
|
29 |
+
* An example for this layout:
|
30 |
+
*
|
31 |
+
* {@example ../../examples/php/layout_html.php 19}<br>
|
32 |
+
*
|
33 |
+
* The corresponding XML file:
|
34 |
+
*
|
35 |
+
* {@example ../../examples/resources/layout_html.properties 18}
|
36 |
+
*
|
37 |
+
* The above will print a HTML table that looks, converted back to plain text, like the following:<br>
|
38 |
+
* <pre>
|
39 |
+
* Log session start time Wed Sep 9 00:11:30 2009
|
40 |
+
*
|
41 |
+
* Time Thread Level Category Message
|
42 |
+
* 0 8318 INFO root Hello World!
|
43 |
+
* </pre>
|
44 |
+
*
|
45 |
+
* @version $Revision: 1379731 $
|
46 |
+
* @package log4php
|
47 |
+
* @subpackage layouts
|
48 |
+
*/
|
49 |
+
class LoggerLayoutHtml extends LoggerLayout {
|
50 |
+
/**
|
51 |
+
* The <b>LocationInfo</b> option takes a boolean value. By
|
52 |
+
* default, it is set to false which means there will be no location
|
53 |
+
* information output by this layout. If the the option is set to
|
54 |
+
* true, then the file name and line number of the statement
|
55 |
+
* at the origin of the log statement will be output.
|
56 |
+
*
|
57 |
+
* <p>If you are embedding this layout within a {@link LoggerAppenderMail}
|
58 |
+
* or a {@link LoggerAppenderMailEvent} then make sure to set the
|
59 |
+
* <b>LocationInfo</b> option of that appender as well.
|
60 |
+
* @var boolean
|
61 |
+
*/
|
62 |
+
protected $locationInfo = false;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* The <b>Title</b> option takes a String value. This option sets the
|
66 |
+
* document title of the generated HTML document.
|
67 |
+
* Defaults to 'Log4php Log Messages'.
|
68 |
+
* @var string
|
69 |
+
*/
|
70 |
+
protected $title = "Log4php Log Messages";
|
71 |
+
|
72 |
+
/**
|
73 |
+
* The <b>LocationInfo</b> option takes a boolean value. By
|
74 |
+
* default, it is set to false which means there will be no location
|
75 |
+
* information output by this layout. If the the option is set to
|
76 |
+
* true, then the file name and line number of the statement
|
77 |
+
* at the origin of the log statement will be output.
|
78 |
+
*
|
79 |
+
* <p>If you are embedding this layout within a {@link LoggerAppenderMail}
|
80 |
+
* or a {@link LoggerAppenderMailEvent} then make sure to set the
|
81 |
+
* <b>LocationInfo</b> option of that appender as well.
|
82 |
+
*/
|
83 |
+
public function setLocationInfo($flag) {
|
84 |
+
$this->setBoolean('locationInfo', $flag);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Returns the current value of the <b>LocationInfo</b> option.
|
89 |
+
*/
|
90 |
+
public function getLocationInfo() {
|
91 |
+
return $this->locationInfo;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* The <b>Title</b> option takes a String value. This option sets the
|
96 |
+
* document title of the generated HTML document.
|
97 |
+
* Defaults to 'Log4php Log Messages'.
|
98 |
+
*/
|
99 |
+
public function setTitle($title) {
|
100 |
+
$this->setString('title', $title);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @return string Returns the current value of the <b>Title</b> option.
|
105 |
+
*/
|
106 |
+
public function getTitle() {
|
107 |
+
return $this->title;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @return string Returns the content type output by this layout, i.e "text/html".
|
112 |
+
*/
|
113 |
+
public function getContentType() {
|
114 |
+
return "text/html";
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* @param LoggerLoggingEvent $event
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
public function format(LoggerLoggingEvent $event) {
|
122 |
+
$sbuf = PHP_EOL . "<tr>" . PHP_EOL;
|
123 |
+
|
124 |
+
$sbuf .= "<td>";
|
125 |
+
$sbuf .= round(1000 * $event->getRelativeTime());
|
126 |
+
$sbuf .= "</td>" . PHP_EOL;
|
127 |
+
|
128 |
+
$sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
|
129 |
+
$sbuf .= $event->getThreadName();
|
130 |
+
$sbuf .= "</td>" . PHP_EOL;
|
131 |
+
|
132 |
+
$sbuf .= "<td title=\"Level\">";
|
133 |
+
|
134 |
+
$level = $event->getLevel();
|
135 |
+
|
136 |
+
if ($level->equals(LoggerLevel::getLevelDebug())) {
|
137 |
+
$sbuf .= "<font color=\"#339933\">$level</font>";
|
138 |
+
} else if ($level->equals(LoggerLevel::getLevelWarn())) {
|
139 |
+
$sbuf .= "<font color=\"#993300\"><strong>$level</strong></font>";
|
140 |
+
} else {
|
141 |
+
$sbuf .= $level;
|
142 |
+
}
|
143 |
+
$sbuf .= "</td>" . PHP_EOL;
|
144 |
+
|
145 |
+
$sbuf .= "<td title=\"" . htmlentities($event->getLoggerName(), ENT_QUOTES) . " category\">";
|
146 |
+
$sbuf .= htmlentities($event->getLoggerName(), ENT_QUOTES);
|
147 |
+
$sbuf .= "</td>" . PHP_EOL;
|
148 |
+
|
149 |
+
if ($this->locationInfo) {
|
150 |
+
$locInfo = $event->getLocationInformation();
|
151 |
+
$sbuf .= "<td>";
|
152 |
+
$sbuf .= htmlentities($locInfo->getFileName(), ENT_QUOTES). ':' . $locInfo->getLineNumber();
|
153 |
+
$sbuf .= "</td>" . PHP_EOL;
|
154 |
+
}
|
155 |
+
|
156 |
+
$sbuf .= "<td title=\"Message\">";
|
157 |
+
$sbuf .= htmlentities($event->getRenderedMessage(), ENT_QUOTES);
|
158 |
+
$sbuf .= "</td>" . PHP_EOL;
|
159 |
+
|
160 |
+
$sbuf .= "</tr>" . PHP_EOL;
|
161 |
+
|
162 |
+
if ($event->getNDC() != null) {
|
163 |
+
$sbuf .= "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">";
|
164 |
+
$sbuf .= "NDC: " . htmlentities($event->getNDC(), ENT_QUOTES);
|
165 |
+
$sbuf .= "</td></tr>" . PHP_EOL;
|
166 |
+
}
|
167 |
+
return $sbuf;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* @return string Returns appropriate HTML headers.
|
172 |
+
*/
|
173 |
+
public function getHeader() {
|
174 |
+
$sbuf = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . PHP_EOL;
|
175 |
+
$sbuf .= "<html>" . PHP_EOL;
|
176 |
+
$sbuf .= "<head>" . PHP_EOL;
|
177 |
+
$sbuf .= "<title>" . $this->title . "</title>" . PHP_EOL;
|
178 |
+
$sbuf .= "<style type=\"text/css\">" . PHP_EOL;
|
179 |
+
$sbuf .= "<!--" . PHP_EOL;
|
180 |
+
$sbuf .= "body, table {font-family: arial,sans-serif; font-size: x-small;}" . PHP_EOL;
|
181 |
+
$sbuf .= "th {background: #336699; color: #FFFFFF; text-align: left;}" . PHP_EOL;
|
182 |
+
$sbuf .= "-->" . PHP_EOL;
|
183 |
+
$sbuf .= "</style>" . PHP_EOL;
|
184 |
+
$sbuf .= "</head>" . PHP_EOL;
|
185 |
+
$sbuf .= "<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">" . PHP_EOL;
|
186 |
+
$sbuf .= "<hr size=\"1\" noshade>" . PHP_EOL;
|
187 |
+
$sbuf .= "Log session start time " . strftime('%c', time()) . "<br>" . PHP_EOL;
|
188 |
+
$sbuf .= "<br>" . PHP_EOL;
|
189 |
+
$sbuf .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">" . PHP_EOL;
|
190 |
+
$sbuf .= "<tr>" . PHP_EOL;
|
191 |
+
$sbuf .= "<th>Time</th>" . PHP_EOL;
|
192 |
+
$sbuf .= "<th>Thread</th>" . PHP_EOL;
|
193 |
+
$sbuf .= "<th>Level</th>" . PHP_EOL;
|
194 |
+
$sbuf .= "<th>Category</th>" . PHP_EOL;
|
195 |
+
if ($this->locationInfo) {
|
196 |
+
$sbuf .= "<th>File:Line</th>" . PHP_EOL;
|
197 |
+
}
|
198 |
+
$sbuf .= "<th>Message</th>" . PHP_EOL;
|
199 |
+
$sbuf .= "</tr>" . PHP_EOL;
|
200 |
+
|
201 |
+
return $sbuf;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @return string Returns the appropriate HTML footers.
|
206 |
+
*/
|
207 |
+
public function getFooter() {
|
208 |
+
$sbuf = "</table>" . PHP_EOL;
|
209 |
+
$sbuf .= "<br>" . PHP_EOL;
|
210 |
+
$sbuf .= "</body></html>";
|
211 |
+
|
212 |
+
return $sbuf;
|
213 |
+
}
|
214 |
+
}
|
lib/Log4php/layouts/LoggerLayoutPattern.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* A flexible layout configurable with a pattern string.
|
23 |
+
*
|
24 |
+
* Configurable parameters:
|
25 |
+
*
|
26 |
+
* * converionPattern - A string which controls the formatting of logging
|
27 |
+
* events. See docs for full specification.
|
28 |
+
*
|
29 |
+
* @package log4php
|
30 |
+
* @subpackage layouts
|
31 |
+
* @version $Revision: 1395470 $
|
32 |
+
*/
|
33 |
+
class LoggerLayoutPattern extends LoggerLayout {
|
34 |
+
|
35 |
+
/** Default conversion pattern */
|
36 |
+
const DEFAULT_CONVERSION_PATTERN = '%date %-5level %logger %message%newline';
|
37 |
+
|
38 |
+
/** Default conversion TTCC Pattern */
|
39 |
+
const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
|
40 |
+
|
41 |
+
/** The conversion pattern. */
|
42 |
+
protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
|
43 |
+
|
44 |
+
/** Maps conversion keywords to the relevant converter (default implementation). */
|
45 |
+
protected static $defaultConverterMap = array(
|
46 |
+
'c' => 'LoggerPatternConverterLogger',
|
47 |
+
'lo' => 'LoggerPatternConverterLogger',
|
48 |
+
'logger' => 'LoggerPatternConverterLogger',
|
49 |
+
|
50 |
+
'C' => 'LoggerPatternConverterClass',
|
51 |
+
'class' => 'LoggerPatternConverterClass',
|
52 |
+
|
53 |
+
'cookie' => 'LoggerPatternConverterCookie',
|
54 |
+
|
55 |
+
'd' => 'LoggerPatternConverterDate',
|
56 |
+
'date' => 'LoggerPatternConverterDate',
|
57 |
+
|
58 |
+
'e' => 'LoggerPatternConverterEnvironment',
|
59 |
+
'env' => 'LoggerPatternConverterEnvironment',
|
60 |
+
|
61 |
+
'ex' => 'LoggerPatternConverterThrowable',
|
62 |
+
'exception' => 'LoggerPatternConverterThrowable',
|
63 |
+
'throwable' => 'LoggerPatternConverterThrowable',
|
64 |
+
|
65 |
+
'F' => 'LoggerPatternConverterFile',
|
66 |
+
'file' => 'LoggerPatternConverterFile',
|
67 |
+
|
68 |
+
'l' => 'LoggerPatternConverterLocation',
|
69 |
+
'location' => 'LoggerPatternConverterLocation',
|
70 |
+
|
71 |
+
'L' => 'LoggerPatternConverterLine',
|
72 |
+
'line' => 'LoggerPatternConverterLine',
|
73 |
+
|
74 |
+
'm' => 'LoggerPatternConverterMessage',
|
75 |
+
'msg' => 'LoggerPatternConverterMessage',
|
76 |
+
'message' => 'LoggerPatternConverterMessage',
|
77 |
+
|
78 |
+
'M' => 'LoggerPatternConverterMethod',
|
79 |
+
'method' => 'LoggerPatternConverterMethod',
|
80 |
+
|
81 |
+
'n' => 'LoggerPatternConverterNewLine',
|
82 |
+
'newline' => 'LoggerPatternConverterNewLine',
|
83 |
+
|
84 |
+
'p' => 'LoggerPatternConverterLevel',
|
85 |
+
'le' => 'LoggerPatternConverterLevel',
|
86 |
+
'level' => 'LoggerPatternConverterLevel',
|
87 |
+
|
88 |
+
'r' => 'LoggerPatternConverterRelative',
|
89 |
+
'relative' => 'LoggerPatternConverterRelative',
|
90 |
+
|
91 |
+
'req' => 'LoggerPatternConverterRequest',
|
92 |
+
'request' => 'LoggerPatternConverterRequest',
|
93 |
+
|
94 |
+
's' => 'LoggerPatternConverterServer',
|
95 |
+
'server' => 'LoggerPatternConverterServer',
|
96 |
+
|
97 |
+
'ses' => 'LoggerPatternConverterSession',
|
98 |
+
'session' => 'LoggerPatternConverterSession',
|
99 |
+
|
100 |
+
'sid' => 'LoggerPatternConverterSessionID',
|
101 |
+
'sessionid' => 'LoggerPatternConverterSessionID',
|
102 |
+
|
103 |
+
't' => 'LoggerPatternConverterProcess',
|
104 |
+
'pid' => 'LoggerPatternConverterProcess',
|
105 |
+
'process' => 'LoggerPatternConverterProcess',
|
106 |
+
|
107 |
+
'x' => 'LoggerPatternConverterNDC',
|
108 |
+
'ndc' => 'LoggerPatternConverterNDC',
|
109 |
+
|
110 |
+
'X' => 'LoggerPatternConverterMDC',
|
111 |
+
'mdc' => 'LoggerPatternConverterMDC',
|
112 |
+
);
|
113 |
+
|
114 |
+
/** Maps conversion keywords to the relevant converter. */
|
115 |
+
protected $converterMap = array();
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Head of a chain of Converters.
|
119 |
+
* @var LoggerPatternConverter
|
120 |
+
*/
|
121 |
+
private $head;
|
122 |
+
|
123 |
+
/** Returns the default converter map. */
|
124 |
+
public static function getDefaultConverterMap() {
|
125 |
+
return self::$defaultConverterMap;
|
126 |
+
}
|
127 |
+
|
128 |
+
/** Constructor. Initializes the converter map. */
|
129 |
+
public function __construct() {
|
130 |
+
$this->converterMap = self::$defaultConverterMap;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Sets the conversionPattern option. This is the string which
|
135 |
+
* controls formatting and consists of a mix of literal content and
|
136 |
+
* conversion specifiers.
|
137 |
+
* @param array $conversionPattern
|
138 |
+
*/
|
139 |
+
public function setConversionPattern($conversionPattern) {
|
140 |
+
$this->pattern = $conversionPattern;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Processes the conversion pattern and creates a corresponding chain of
|
145 |
+
* pattern converters which will be used to format logging events.
|
146 |
+
*/
|
147 |
+
public function activateOptions() {
|
148 |
+
if (!isset($this->pattern)) {
|
149 |
+
throw new LoggerException("Mandatory parameter 'conversionPattern' is not set.");
|
150 |
+
}
|
151 |
+
|
152 |
+
$parser = new LoggerPatternParser($this->pattern, $this->converterMap);
|
153 |
+
$this->head = $parser->parse();
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Produces a formatted string as specified by the conversion pattern.
|
158 |
+
*
|
159 |
+
* @param LoggerLoggingEvent $event
|
160 |
+
* @return string
|
161 |
+
*/
|
162 |
+
public function format(LoggerLoggingEvent $event) {
|
163 |
+
$sbuf = '';
|
164 |
+
$converter = $this->head;
|
165 |
+
while ($converter !== null) {
|
166 |
+
$converter->format($sbuf, $event);
|
167 |
+
$converter = $converter->next;
|
168 |
+
}
|
169 |
+
return $sbuf;
|
170 |
+
}
|
171 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutSerialized.php
RENAMED
@@ -25,7 +25,7 @@
|
|
25 |
* - locationInfo - If set to true, the event's location information will also
|
26 |
* be serialized (slow, defaults to false).
|
27 |
*
|
28 |
-
* @version $Revision:
|
29 |
* @package log4php
|
30 |
* @subpackage layouts
|
31 |
* @since 2.2
|
25 |
* - locationInfo - If set to true, the event's location information will also
|
26 |
* be serialized (slow, defaults to false).
|
27 |
*
|
28 |
+
* @version $Revision: 1334369 $
|
29 |
* @package log4php
|
30 |
* @subpackage layouts
|
31 |
* @since 2.2
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutSimple.php
RENAMED
@@ -1,56 +1,56 @@
|
|
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 |
-
/**
|
22 |
-
* A simple layout.
|
23 |
-
*
|
24 |
-
* Returns the log statement in a format consisting of the
|
25 |
-
* <b>level</b>, followed by " - " and then the <b>message</b>.
|
26 |
-
*
|
27 |
-
* For example the following php and properties files
|
28 |
-
*
|
29 |
-
* {@example ../../examples/php/layout_simple.php 19}<br>
|
30 |
-
*
|
31 |
-
* {@example ../../examples/resources/layout_simple.properties 18}<br>
|
32 |
-
*
|
33 |
-
* would result in:
|
34 |
-
*
|
35 |
-
* <samp>INFO - Hello World!</samp>
|
36 |
-
*
|
37 |
-
* @version $Revision: 1213283 $
|
38 |
-
* @package log4php
|
39 |
-
* @subpackage layouts
|
40 |
-
*/
|
41 |
-
class LoggerLayoutSimple extends LoggerLayout {
|
42 |
-
/**
|
43 |
-
* Returns the log statement in a format consisting of the
|
44 |
-
* <b>level</b>, followed by " - " and then the
|
45 |
-
* <b>message</b>. For example,
|
46 |
-
* <samp> INFO - "A message" </samp>
|
47 |
-
*
|
48 |
-
* @param LoggerLoggingEvent $event
|
49 |
-
* @return string
|
50 |
-
*/
|
51 |
-
public function format(LoggerLoggingEvent $event) {
|
52 |
-
$level = $event->getLevel();
|
53 |
-
$message = $event->getRenderedMessage();
|
54 |
-
return "$level - $message" . PHP_EOL;
|
55 |
-
}
|
56 |
-
}
|
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 |
+
/**
|
22 |
+
* A simple layout.
|
23 |
+
*
|
24 |
+
* Returns the log statement in a format consisting of the
|
25 |
+
* <b>level</b>, followed by " - " and then the <b>message</b>.
|
26 |
+
*
|
27 |
+
* For example the following php and properties files
|
28 |
+
*
|
29 |
+
* {@example ../../examples/php/layout_simple.php 19}<br>
|
30 |
+
*
|
31 |
+
* {@example ../../examples/resources/layout_simple.properties 18}<br>
|
32 |
+
*
|
33 |
+
* would result in:
|
34 |
+
*
|
35 |
+
* <samp>INFO - Hello World!</samp>
|
36 |
+
*
|
37 |
+
* @version $Revision: 1213283 $
|
38 |
+
* @package log4php
|
39 |
+
* @subpackage layouts
|
40 |
+
*/
|
41 |
+
class LoggerLayoutSimple extends LoggerLayout {
|
42 |
+
/**
|
43 |
+
* Returns the log statement in a format consisting of the
|
44 |
+
* <b>level</b>, followed by " - " and then the
|
45 |
+
* <b>message</b>. For example,
|
46 |
+
* <samp> INFO - "A message" </samp>
|
47 |
+
*
|
48 |
+
* @param LoggerLoggingEvent $event
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
public function format(LoggerLoggingEvent $event) {
|
52 |
+
$level = $event->getLevel();
|
53 |
+
$message = $event->getRenderedMessage();
|
54 |
+
return "$level - $message" . PHP_EOL;
|
55 |
+
}
|
56 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutTTCC.php
RENAMED
@@ -1,197 +1,201 @@
|
|
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 |
-
/**
|
22 |
-
* TTCC layout format consists of <b>t</b>ime, <b>t</b>hread, <b>c</b>ategory and nested
|
23 |
-
* diagnostic <b>c</b>ontext information, hence the name.
|
24 |
-
*
|
25 |
-
* <p>Each of the four fields can be individually enabled or
|
26 |
-
* disabled. The time format depends on the <b>DateFormat</b> used.</p>
|
27 |
-
*
|
28 |
-
* <p>If no dateFormat is specified it defaults to '%c'.
|
29 |
-
* See php {@link PHP_MANUAL#date} function for details.</p>
|
30 |
-
*
|
31 |
-
* Configurable parameters for this layout are:
|
32 |
-
* - {@link $threadPrinting} (true|false) enable/disable pid reporting.
|
33 |
-
* - {@link $categoryPrefixing} (true|false) enable/disable logger category reporting.
|
34 |
-
* - {@link $contextPrinting} (true|false) enable/disable NDC reporting.
|
35 |
-
* - {@link $microSecondsPrinting} (true|false) enable/disable micro seconds reporting in timestamp.
|
36 |
-
* - {@link $dateFormat} (string) set date format. See php {@link PHP_MANUAL#date} function for details.
|
37 |
-
*
|
38 |
-
* An example how to use this layout:
|
39 |
-
*
|
40 |
-
* {@example ../../examples/php/layout_ttcc.php 19}<br>
|
41 |
-
*
|
42 |
-
* {@example ../../examples/resources/layout_ttcc.properties 18}<br>
|
43 |
-
*
|
44 |
-
* The above would print:<br>
|
45 |
-
* <samp>02:28 [13714] INFO root - Hello World!</samp>
|
46 |
-
*
|
47 |
-
* @version $Revision:
|
48 |
-
* @package log4php
|
49 |
-
* @subpackage layouts
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
protected $
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
*
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
*
|
157 |
-
*
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
if($this->
|
182 |
-
$
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
return
|
196 |
-
}
|
197 |
-
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* TTCC layout format consists of <b>t</b>ime, <b>t</b>hread, <b>c</b>ategory and nested
|
23 |
+
* diagnostic <b>c</b>ontext information, hence the name.
|
24 |
+
*
|
25 |
+
* <p>Each of the four fields can be individually enabled or
|
26 |
+
* disabled. The time format depends on the <b>DateFormat</b> used.</p>
|
27 |
+
*
|
28 |
+
* <p>If no dateFormat is specified it defaults to '%c'.
|
29 |
+
* See php {@link PHP_MANUAL#date} function for details.</p>
|
30 |
+
*
|
31 |
+
* Configurable parameters for this layout are:
|
32 |
+
* - {@link $threadPrinting} (true|false) enable/disable pid reporting.
|
33 |
+
* - {@link $categoryPrefixing} (true|false) enable/disable logger category reporting.
|
34 |
+
* - {@link $contextPrinting} (true|false) enable/disable NDC reporting.
|
35 |
+
* - {@link $microSecondsPrinting} (true|false) enable/disable micro seconds reporting in timestamp.
|
36 |
+
* - {@link $dateFormat} (string) set date format. See php {@link PHP_MANUAL#date} function for details.
|
37 |
+
*
|
38 |
+
* An example how to use this layout:
|
39 |
+
*
|
40 |
+
* {@example ../../examples/php/layout_ttcc.php 19}<br>
|
41 |
+
*
|
42 |
+
* {@example ../../examples/resources/layout_ttcc.properties 18}<br>
|
43 |
+
*
|
44 |
+
* The above would print:<br>
|
45 |
+
* <samp>02:28 [13714] INFO root - Hello World!</samp>
|
46 |
+
*
|
47 |
+
* @version $Revision: 1302503 $
|
48 |
+
* @package log4php
|
49 |
+
* @subpackage layouts
|
50 |
+
*
|
51 |
+
* @deprecated LoggerLayout TTCC is deprecated and will be removed in a future release. Please use
|
52 |
+
* LoggerLayoutPattern instead.
|
53 |
+
*/
|
54 |
+
class LoggerLayoutTTCC extends LoggerLayout {
|
55 |
+
|
56 |
+
// Internal representation of options
|
57 |
+
protected $threadPrinting = true;
|
58 |
+
protected $categoryPrefixing = true;
|
59 |
+
protected $contextPrinting = true;
|
60 |
+
protected $microSecondsPrinting = true;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @var string date format. See {@link PHP_MANUAL#strftime} for details
|
64 |
+
*/
|
65 |
+
protected $dateFormat = '%c';
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Constructor
|
69 |
+
*
|
70 |
+
* @param string date format
|
71 |
+
* @see dateFormat
|
72 |
+
*/
|
73 |
+
public function __construct($dateFormat = '') {
|
74 |
+
$this->warn("LoggerLayout TTCC is deprecated and will be removed in a future release. Please use LoggerLayoutPattern instead.");
|
75 |
+
if (!empty($dateFormat)) {
|
76 |
+
$this->dateFormat = $dateFormat;
|
77 |
+
}
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* The <b>ThreadPrinting</b> option specifies whether the name of the
|
83 |
+
* current thread is part of log output or not. This is true by default.
|
84 |
+
*/
|
85 |
+
public function setThreadPrinting($threadPrinting) {
|
86 |
+
$this->setBoolean('threadPrinting', $threadPrinting);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @return boolean Returns value of the <b>ThreadPrinting</b> option.
|
91 |
+
*/
|
92 |
+
public function getThreadPrinting() {
|
93 |
+
return $this->threadPrinting;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* The <b>CategoryPrefixing</b> option specifies whether {@link Category}
|
98 |
+
* name is part of log output or not. This is true by default.
|
99 |
+
*/
|
100 |
+
public function setCategoryPrefixing($categoryPrefixing) {
|
101 |
+
$this->setBoolean('categoryPrefixing', $categoryPrefixing);
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @return boolean Returns value of the <b>CategoryPrefixing</b> option.
|
106 |
+
*/
|
107 |
+
public function getCategoryPrefixing() {
|
108 |
+
return $this->categoryPrefixing;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* The <b>ContextPrinting</b> option specifies log output will include
|
113 |
+
* the nested context information belonging to the current thread.
|
114 |
+
* This is true by default.
|
115 |
+
*/
|
116 |
+
public function setContextPrinting($contextPrinting) {
|
117 |
+
$this->setBoolean('contextPrinting', $contextPrinting);
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @return boolean Returns value of the <b>ContextPrinting</b> option.
|
122 |
+
*/
|
123 |
+
public function getContextPrinting() {
|
124 |
+
return $this->contextPrinting;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* The <b>MicroSecondsPrinting</b> option specifies if microseconds infos
|
129 |
+
* should be printed at the end of timestamp.
|
130 |
+
* This is true by default.
|
131 |
+
*/
|
132 |
+
public function setMicroSecondsPrinting($microSecondsPrinting) {
|
133 |
+
$this->setBoolean('microSecondsPrinting', $microSecondsPrinting);
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @return boolean Returns value of the <b>MicroSecondsPrinting</b> option.
|
138 |
+
*/
|
139 |
+
public function getMicroSecondsPrinting() {
|
140 |
+
return $this->microSecondsPrinting;
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
public function setDateFormat($dateFormat) {
|
145 |
+
$this->setString('dateFormat', $dateFormat);
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* @return string
|
150 |
+
*/
|
151 |
+
public function getDateFormat() {
|
152 |
+
return $this->dateFormat;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* In addition to the level of the statement and message, the
|
157 |
+
* returned string includes time, thread, category.
|
158 |
+
* <p>Time, thread, category are printed depending on options.
|
159 |
+
*
|
160 |
+
* @param LoggerLoggingEvent $event
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
public function format(LoggerLoggingEvent $event) {
|
164 |
+
$timeStamp = (float)$event->getTimeStamp();
|
165 |
+
$format = strftime($this->dateFormat, (int)$timeStamp);
|
166 |
+
|
167 |
+
if ($this->microSecondsPrinting) {
|
168 |
+
$usecs = floor(($timeStamp - (int)$timeStamp) * 1000);
|
169 |
+
$format .= sprintf(',%03d', $usecs);
|
170 |
+
}
|
171 |
+
|
172 |
+
$format .= ' ';
|
173 |
+
|
174 |
+
if ($this->threadPrinting) {
|
175 |
+
$format .= '['.getmypid().'] ';
|
176 |
+
}
|
177 |
+
|
178 |
+
$level = $event->getLevel();
|
179 |
+
$format .= $level.' ';
|
180 |
+
|
181 |
+
if($this->categoryPrefixing) {
|
182 |
+
$format .= $event->getLoggerName().' ';
|
183 |
+
}
|
184 |
+
|
185 |
+
if($this->contextPrinting) {
|
186 |
+
$ndc = $event->getNDC();
|
187 |
+
if($ndc != null) {
|
188 |
+
$format .= $ndc.' ';
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
$format .= '- '.$event->getRenderedMessage();
|
193 |
+
$format .= PHP_EOL;
|
194 |
+
|
195 |
+
return $format;
|
196 |
+
}
|
197 |
+
|
198 |
+
public function ignoresThrowable() {
|
199 |
+
return true;
|
200 |
+
}
|
201 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/layouts/LoggerLayoutXml.php
RENAMED
@@ -1,210 +1,210 @@
|
|
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 |
-
/**
|
22 |
-
* The output of the LoggerXmlLayout consists of a series of log4php:event elements.
|
23 |
-
*
|
24 |
-
* Configurable parameters:
|
25 |
-
* - {@link $locationInfo} - If set to true then the file name and line number
|
26 |
-
* of the origin of the log statement will be included in output.
|
27 |
-
* - {@link $log4jNamespace} - If set to true then log4j namespace will be used
|
28 |
-
* instead of log4php namespace. This can be usefull when using log viewers
|
29 |
-
* which can only parse the log4j namespace such as Apache Chainsaw.
|
30 |
-
*
|
31 |
-
* <p>It does not output a complete well-formed XML file.
|
32 |
-
* The output is designed to be included as an external entity in a separate file to form
|
33 |
-
* a correct XML file.</p>
|
34 |
-
*
|
35 |
-
* Example:
|
36 |
-
*
|
37 |
-
* {@example ../../examples/php/layout_xml.php 19}<br>
|
38 |
-
*
|
39 |
-
* {@example ../../examples/resources/layout_xml.properties 18}<br>
|
40 |
-
*
|
41 |
-
* The above would print:
|
42 |
-
*
|
43 |
-
* <pre>
|
44 |
-
* <log4php:eventSet xmlns:log4php="http://logging.apache.org/log4php/" version="0.3" includesLocationInfo="true">
|
45 |
-
* <log4php:event logger="root" level="INFO" thread="13802" timestamp="1252456226491">
|
46 |
-
* <log4php:message><![CDATA[Hello World!]]></log4php:message>
|
47 |
-
* <log4php:locationInfo class="main" file="examples/php/layout_xml.php" line="6" method="main" />
|
48 |
-
* </log4php:event>
|
49 |
-
* </log4php:eventSet>
|
50 |
-
* </pre>
|
51 |
-
*
|
52 |
-
* @version $Revision: 1213283 $
|
53 |
-
* @package log4php
|
54 |
-
* @subpackage layouts
|
55 |
-
*/
|
56 |
-
class LoggerLayoutXml extends LoggerLayout {
|
57 |
-
const LOG4J_NS_PREFIX ='log4j';
|
58 |
-
const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
|
59 |
-
|
60 |
-
const LOG4PHP_NS_PREFIX = 'log4php';
|
61 |
-
const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
|
62 |
-
|
63 |
-
const CDATA_START = '<![CDATA[';
|
64 |
-
const CDATA_END = ']]>';
|
65 |
-
const CDATA_PSEUDO_END = ']]>';
|
66 |
-
const CDATA_EMBEDDED_END = ']]>]]><![CDATA[';
|
67 |
-
|
68 |
-
/**
|
69 |
-
* If set to true then the file name and line number of the origin of the
|
70 |
-
* log statement will be output.
|
71 |
-
* @var boolean
|
72 |
-
*/
|
73 |
-
protected $locationInfo = true;
|
74 |
-
|
75 |
-
/**
|
76 |
-
* If set to true, log4j namespace will be used instead of the log4php
|
77 |
-
* namespace.
|
78 |
-
* @var boolean
|
79 |
-
*/
|
80 |
-
protected $log4jNamespace = false;
|
81 |
-
|
82 |
-
/** The namespace in use. */
|
83 |
-
protected $namespace = self::LOG4PHP_NS;
|
84 |
-
|
85 |
-
/** The namespace prefix in use */
|
86 |
-
protected $namespacePrefix = self::LOG4PHP_NS_PREFIX;
|
87 |
-
|
88 |
-
public function activateOptions() {
|
89 |
-
if ($this->getLog4jNamespace()) {
|
90 |
-
$this->namespace = self::LOG4J_NS;
|
91 |
-
$this->namespacePrefix = self::LOG4J_NS_PREFIX;
|
92 |
-
} else {
|
93 |
-
$this->namespace = self::LOG4PHP_NS;
|
94 |
-
$this->namespacePrefix = self::LOG4PHP_NS_PREFIX;
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* @return string
|
100 |
-
*/
|
101 |
-
public function getHeader() {
|
102 |
-
return "<{$this->namespacePrefix}:eventSet ".
|
103 |
-
"xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
|
104 |
-
"version=\"0.3\" ".
|
105 |
-
"includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
|
106 |
-
">" . PHP_EOL;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd.
|
111 |
-
*
|
112 |
-
* @param LoggerLoggingEvent $event
|
113 |
-
* @return string
|
114 |
-
*/
|
115 |
-
public function format(LoggerLoggingEvent $event) {
|
116 |
-
$ns = $this->namespacePrefix;
|
117 |
-
|
118 |
-
$loggerName = $event->getLoggerName();
|
119 |
-
$timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', '');
|
120 |
-
$thread = $event->getThreadName();
|
121 |
-
$level = $event->getLevel()->toString();
|
122 |
-
|
123 |
-
$buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
|
124 |
-
$buf .= "<$ns:message>";
|
125 |
-
$buf .= $this->encodeCDATA($event->getRenderedMessage());
|
126 |
-
$buf .= "</$ns:message>".PHP_EOL;
|
127 |
-
|
128 |
-
$ndc = $event->getNDC();
|
129 |
-
if(!empty($ndc)) {
|
130 |
-
$buf .= "<$ns:NDC><![CDATA[";
|
131 |
-
$buf .= $this->encodeCDATA($ndc);
|
132 |
-
$buf .= "]]></$ns:NDC>".PHP_EOL;
|
133 |
-
}
|
134 |
-
|
135 |
-
$mdcMap = $event->getMDCMap();
|
136 |
-
if (!empty($mdcMap)) {
|
137 |
-
$buf .= "<$ns:properties>".PHP_EOL;
|
138 |
-
foreach ($mdcMap as $name=>$value) {
|
139 |
-
$buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL;
|
140 |
-
}
|
141 |
-
$buf .= "</$ns:properties>".PHP_EOL;
|
142 |
-
}
|
143 |
-
|
144 |
-
if ($this->getLocationInfo()) {
|
145 |
-
$locationInfo = $event->getLocationInformation();
|
146 |
-
$buf .= "<$ns:locationInfo ".
|
147 |
-
"class=\"" . $locationInfo->getClassName() . "\" ".
|
148 |
-
"file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ".
|
149 |
-
"line=\"" . $locationInfo->getLineNumber() . "\" ".
|
150 |
-
"method=\"" . $locationInfo->getMethodName() . "\" ";
|
151 |
-
$buf .= "/>".PHP_EOL;
|
152 |
-
}
|
153 |
-
|
154 |
-
$buf .= "</$ns:event>".PHP_EOL;
|
155 |
-
|
156 |
-
return $buf;
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* @return string
|
161 |
-
*/
|
162 |
-
public function getFooter() {
|
163 |
-
return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL;
|
164 |
-
}
|
165 |
-
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Whether or not file name and line number will be included in the output.
|
169 |
-
* @return boolean
|
170 |
-
*/
|
171 |
-
public function getLocationInfo() {
|
172 |
-
return $this->locationInfo;
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* The {@link $locationInfo} option takes a boolean value. By default,
|
177 |
-
* it is set to false which means there will be no location
|
178 |
-
* information output by this layout. If the the option is set to
|
179 |
-
* true, then the file name and line number of the statement at the
|
180 |
-
* origin of the log statement will be output.
|
181 |
-
*/
|
182 |
-
public function setLocationInfo($flag) {
|
183 |
-
$this->setBoolean('locationInfo', $flag);
|
184 |
-
}
|
185 |
-
|
186 |
-
/**
|
187 |
-
* @return boolean
|
188 |
-
*/
|
189 |
-
public function getLog4jNamespace() {
|
190 |
-
return $this->log4jNamespace;
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* @param boolean
|
195 |
-
*/
|
196 |
-
public function setLog4jNamespace($flag) {
|
197 |
-
$this->setBoolean('log4jNamespace', $flag);
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Encases a string in CDATA tags, and escapes any existing CDATA end
|
202 |
-
* tags already present in the string.
|
203 |
-
* @param string $string
|
204 |
-
*/
|
205 |
-
private function encodeCDATA($string) {
|
206 |
-
$string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
|
207 |
-
return self::CDATA_START . $string . self::CDATA_END;
|
208 |
-
}
|
209 |
-
}
|
210 |
-
|
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 |
+
/**
|
22 |
+
* The output of the LoggerXmlLayout consists of a series of log4php:event elements.
|
23 |
+
*
|
24 |
+
* Configurable parameters:
|
25 |
+
* - {@link $locationInfo} - If set to true then the file name and line number
|
26 |
+
* of the origin of the log statement will be included in output.
|
27 |
+
* - {@link $log4jNamespace} - If set to true then log4j namespace will be used
|
28 |
+
* instead of log4php namespace. This can be usefull when using log viewers
|
29 |
+
* which can only parse the log4j namespace such as Apache Chainsaw.
|
30 |
+
*
|
31 |
+
* <p>It does not output a complete well-formed XML file.
|
32 |
+
* The output is designed to be included as an external entity in a separate file to form
|
33 |
+
* a correct XML file.</p>
|
34 |
+
*
|
35 |
+
* Example:
|
36 |
+
*
|
37 |
+
* {@example ../../examples/php/layout_xml.php 19}<br>
|
38 |
+
*
|
39 |
+
* {@example ../../examples/resources/layout_xml.properties 18}<br>
|
40 |
+
*
|
41 |
+
* The above would print:
|
42 |
+
*
|
43 |
+
* <pre>
|
44 |
+
* <log4php:eventSet xmlns:log4php="http://logging.apache.org/log4php/" version="0.3" includesLocationInfo="true">
|
45 |
+
* <log4php:event logger="root" level="INFO" thread="13802" timestamp="1252456226491">
|
46 |
+
* <log4php:message><![CDATA[Hello World!]]></log4php:message>
|
47 |
+
* <log4php:locationInfo class="main" file="examples/php/layout_xml.php" line="6" method="main" />
|
48 |
+
* </log4php:event>
|
49 |
+
* </log4php:eventSet>
|
50 |
+
* </pre>
|
51 |
+
*
|
52 |
+
* @version $Revision: 1213283 $
|
53 |
+
* @package log4php
|
54 |
+
* @subpackage layouts
|
55 |
+
*/
|
56 |
+
class LoggerLayoutXml extends LoggerLayout {
|
57 |
+
const LOG4J_NS_PREFIX ='log4j';
|
58 |
+
const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
|
59 |
+
|
60 |
+
const LOG4PHP_NS_PREFIX = 'log4php';
|
61 |
+
const LOG4PHP_NS = 'http://logging.apache.org/log4php/';
|
62 |
+
|
63 |
+
const CDATA_START = '<![CDATA[';
|
64 |
+
const CDATA_END = ']]>';
|
65 |
+
const CDATA_PSEUDO_END = ']]>';
|
66 |
+
const CDATA_EMBEDDED_END = ']]>]]><![CDATA[';
|
67 |
+
|
68 |
+
/**
|
69 |
+
* If set to true then the file name and line number of the origin of the
|
70 |
+
* log statement will be output.
|
71 |
+
* @var boolean
|
72 |
+
*/
|
73 |
+
protected $locationInfo = true;
|
74 |
+
|
75 |
+
/**
|
76 |
+
* If set to true, log4j namespace will be used instead of the log4php
|
77 |
+
* namespace.
|
78 |
+
* @var boolean
|
79 |
+
*/
|
80 |
+
protected $log4jNamespace = false;
|
81 |
+
|
82 |
+
/** The namespace in use. */
|
83 |
+
protected $namespace = self::LOG4PHP_NS;
|
84 |
+
|
85 |
+
/** The namespace prefix in use */
|
86 |
+
protected $namespacePrefix = self::LOG4PHP_NS_PREFIX;
|
87 |
+
|
88 |
+
public function activateOptions() {
|
89 |
+
if ($this->getLog4jNamespace()) {
|
90 |
+
$this->namespace = self::LOG4J_NS;
|
91 |
+
$this->namespacePrefix = self::LOG4J_NS_PREFIX;
|
92 |
+
} else {
|
93 |
+
$this->namespace = self::LOG4PHP_NS;
|
94 |
+
$this->namespacePrefix = self::LOG4PHP_NS_PREFIX;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
public function getHeader() {
|
102 |
+
return "<{$this->namespacePrefix}:eventSet ".
|
103 |
+
"xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
|
104 |
+
"version=\"0.3\" ".
|
105 |
+
"includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
|
106 |
+
">" . PHP_EOL;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Formats a {@link LoggerLoggingEvent} in conformance with the log4php.dtd.
|
111 |
+
*
|
112 |
+
* @param LoggerLoggingEvent $event
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
public function format(LoggerLoggingEvent $event) {
|
116 |
+
$ns = $this->namespacePrefix;
|
117 |
+
|
118 |
+
$loggerName = $event->getLoggerName();
|
119 |
+
$timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', '');
|
120 |
+
$thread = $event->getThreadName();
|
121 |
+
$level = $event->getLevel()->toString();
|
122 |
+
|
123 |
+
$buf = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
|
124 |
+
$buf .= "<$ns:message>";
|
125 |
+
$buf .= $this->encodeCDATA($event->getRenderedMessage());
|
126 |
+
$buf .= "</$ns:message>".PHP_EOL;
|
127 |
+
|
128 |
+
$ndc = $event->getNDC();
|
129 |
+
if(!empty($ndc)) {
|
130 |
+
$buf .= "<$ns:NDC><![CDATA[";
|
131 |
+
$buf .= $this->encodeCDATA($ndc);
|
132 |
+
$buf .= "]]></$ns:NDC>".PHP_EOL;
|
133 |
+
}
|
134 |
+
|
135 |
+
$mdcMap = $event->getMDCMap();
|
136 |
+
if (!empty($mdcMap)) {
|
137 |
+
$buf .= "<$ns:properties>".PHP_EOL;
|
138 |
+
foreach ($mdcMap as $name=>$value) {
|
139 |
+
$buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL;
|
140 |
+
}
|
141 |
+
$buf .= "</$ns:properties>".PHP_EOL;
|
142 |
+
}
|
143 |
+
|
144 |
+
if ($this->getLocationInfo()) {
|
145 |
+
$locationInfo = $event->getLocationInformation();
|
146 |
+
$buf .= "<$ns:locationInfo ".
|
147 |
+
"class=\"" . $locationInfo->getClassName() . "\" ".
|
148 |
+
"file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ".
|
149 |
+
"line=\"" . $locationInfo->getLineNumber() . "\" ".
|
150 |
+
"method=\"" . $locationInfo->getMethodName() . "\" ";
|
151 |
+
$buf .= "/>".PHP_EOL;
|
152 |
+
}
|
153 |
+
|
154 |
+
$buf .= "</$ns:event>".PHP_EOL;
|
155 |
+
|
156 |
+
return $buf;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @return string
|
161 |
+
*/
|
162 |
+
public function getFooter() {
|
163 |
+
return "</{$this->namespacePrefix}:eventSet>" . PHP_EOL;
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Whether or not file name and line number will be included in the output.
|
169 |
+
* @return boolean
|
170 |
+
*/
|
171 |
+
public function getLocationInfo() {
|
172 |
+
return $this->locationInfo;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* The {@link $locationInfo} option takes a boolean value. By default,
|
177 |
+
* it is set to false which means there will be no location
|
178 |
+
* information output by this layout. If the the option is set to
|
179 |
+
* true, then the file name and line number of the statement at the
|
180 |
+
* origin of the log statement will be output.
|
181 |
+
*/
|
182 |
+
public function setLocationInfo($flag) {
|
183 |
+
$this->setBoolean('locationInfo', $flag);
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* @return boolean
|
188 |
+
*/
|
189 |
+
public function getLog4jNamespace() {
|
190 |
+
return $this->log4jNamespace;
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* @param boolean
|
195 |
+
*/
|
196 |
+
public function setLog4jNamespace($flag) {
|
197 |
+
$this->setBoolean('log4jNamespace', $flag);
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Encases a string in CDATA tags, and escapes any existing CDATA end
|
202 |
+
* tags already present in the string.
|
203 |
+
* @param string $string
|
204 |
+
*/
|
205 |
+
private function encodeCDATA($string) {
|
206 |
+
$string = str_replace(self::CDATA_END, self::CDATA_EMBEDDED_END, $string);
|
207 |
+
return self::CDATA_START . $string . self::CDATA_END;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
lib/Log4php/pattern/LoggerPatternConverter.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* LoggerPatternConverter is an abstract class that provides the formatting
|
23 |
+
* functionality that derived classes need.
|
24 |
+
*
|
25 |
+
* <p>Conversion specifiers in a conversion patterns are parsed to
|
26 |
+
* individual PatternConverters. Each of which is responsible for
|
27 |
+
* converting a logging event in a converter specific manner.</p>
|
28 |
+
*
|
29 |
+
* @version $Revision: 1326626 $
|
30 |
+
* @package log4php
|
31 |
+
* @subpackage helpers
|
32 |
+
* @since 0.3
|
33 |
+
*/
|
34 |
+
abstract class LoggerPatternConverter {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Next converter in the converter chain.
|
38 |
+
* @var LoggerPatternConverter
|
39 |
+
*/
|
40 |
+
public $next = null;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Formatting information, parsed from pattern modifiers.
|
44 |
+
* @var LoggerFormattingInfo
|
45 |
+
*/
|
46 |
+
protected $formattingInfo;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Converter-specific formatting options.
|
50 |
+
* @var array
|
51 |
+
*/
|
52 |
+
protected $option;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Constructor
|
56 |
+
* @param LoggerFormattingInfo $formattingInfo
|
57 |
+
* @param array $option
|
58 |
+
*/
|
59 |
+
public function __construct(LoggerFormattingInfo $formattingInfo = null, $option = null) {
|
60 |
+
$this->formattingInfo = $formattingInfo;
|
61 |
+
$this->option = $option;
|
62 |
+
$this->activateOptions();
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Called in constructor. Converters which need to process the options
|
67 |
+
* can override this method.
|
68 |
+
*/
|
69 |
+
public function activateOptions() { }
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Converts the logging event to the desired format. Derived pattern
|
73 |
+
* converters must implement this method.
|
74 |
+
*
|
75 |
+
* @param LoggerLoggingEvent $event
|
76 |
+
*/
|
77 |
+
abstract public function convert(LoggerLoggingEvent $event);
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Converts the event and formats it according to setting in the
|
81 |
+
* Formatting information object.
|
82 |
+
*
|
83 |
+
* @param string &$sbuf string buffer to write to
|
84 |
+
* @param LoggerLoggingEvent $event Event to be formatted.
|
85 |
+
*/
|
86 |
+
public function format(&$sbuf, $event) {
|
87 |
+
$string = $this->convert($event);
|
88 |
+
|
89 |
+
if (!isset($this->formattingInfo)) {
|
90 |
+
$sbuf .= $string;
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
|
94 |
+
$fi = $this->formattingInfo;
|
95 |
+
|
96 |
+
// Empty string
|
97 |
+
if($string === '' || is_null($string)) {
|
98 |
+
if($fi->min > 0) {
|
99 |
+
$sbuf .= str_repeat(' ', $fi->min);
|
100 |
+
}
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
|
104 |
+
$len = strlen($string);
|
105 |
+
|
106 |
+
// Trim the string if needed
|
107 |
+
if($len > $fi->max) {
|
108 |
+
if ($fi->trimLeft) {
|
109 |
+
$sbuf .= substr($string, $len - $fi->max, $fi->max);
|
110 |
+
} else {
|
111 |
+
$sbuf .= substr($string , 0, $fi->max);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
// Add padding if needed
|
116 |
+
else if($len < $fi->min) {
|
117 |
+
if($fi->padLeft) {
|
118 |
+
$sbuf .= str_repeat(' ', $fi->min - $len);
|
119 |
+
$sbuf .= $string;
|
120 |
+
} else {
|
121 |
+
$sbuf .= $string;
|
122 |
+
$sbuf .= str_repeat(' ', $fi->min - $len);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
// No action needed
|
127 |
+
else {
|
128 |
+
$sbuf .= $string;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterClass.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the fully qualified class name of the class from which the logging
|
23 |
+
* request was issued.
|
24 |
+
*
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage pattern
|
27 |
+
* @version $Revision: 1326626 $
|
28 |
+
* @since 2.3
|
29 |
+
*/
|
30 |
+
class LoggerPatternConverterClass extends LoggerPatternConverter {
|
31 |
+
|
32 |
+
/** Length to which to shorten the class name. */
|
33 |
+
private $length;
|
34 |
+
|
35 |
+
/** Holds processed class names. */
|
36 |
+
private $cache = array();
|
37 |
+
|
38 |
+
public function activateOptions() {
|
39 |
+
// Parse the option (desired output length)
|
40 |
+
if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
|
41 |
+
$this->length = (integer) $this->option;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
public function convert(LoggerLoggingEvent $event) {
|
46 |
+
$name = $event->getLocationInformation()->getClassName();
|
47 |
+
|
48 |
+
if (!isset($this->cache[$name])) {
|
49 |
+
|
50 |
+
// If length is set return shortened class name
|
51 |
+
if (isset($this->length)) {
|
52 |
+
$this->cache[$name] = LoggerUtils::shortenClassName($name, $this->length);
|
53 |
+
}
|
54 |
+
|
55 |
+
// If no length is specified return the full class name
|
56 |
+
else {
|
57 |
+
$this->cache[$name] = $name;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
return $this->cache[$name];
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
lib/Log4php/pattern/LoggerPatternConverterCookie.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns a value from the $_COOKIE superglobal array corresponding to the
|
23 |
+
* given key. If no key is given, return all values.
|
24 |
+
*
|
25 |
+
* Options:
|
26 |
+
* [0] $_COOKIE key value
|
27 |
+
*
|
28 |
+
* @package log4php
|
29 |
+
* @subpackage pattern
|
30 |
+
* @version $Revision: 1326626 $
|
31 |
+
* @since 2.3
|
32 |
+
*/
|
33 |
+
class LoggerPatternConverterCookie extends LoggerPatternConverterSuperglobal {
|
34 |
+
protected $name = '_COOKIE';
|
35 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterDate.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the date/time of the logging request.
|
23 |
+
*
|
24 |
+
* Option: the datetime format, as used by the date() function. If
|
25 |
+
* the option is not given, the default format 'c' will be used.
|
26 |
+
*
|
27 |
+
* There are several "special" values which can be given for this option:
|
28 |
+
* 'ISO8601', 'ABSOLUTE' and 'DATE'.
|
29 |
+
*
|
30 |
+
* @package log4php
|
31 |
+
* @subpackage pattern
|
32 |
+
* @version $Revision: 1326626 $
|
33 |
+
* @since 2.3
|
34 |
+
*/
|
35 |
+
class LoggerPatternConverterDate extends LoggerPatternConverter {
|
36 |
+
|
37 |
+
const DATE_FORMAT_ISO8601 = 'c';
|
38 |
+
|
39 |
+
const DATE_FORMAT_ABSOLUTE = 'H:i:s';
|
40 |
+
|
41 |
+
const DATE_FORMAT_DATE = 'd M Y H:i:s.u';
|
42 |
+
|
43 |
+
private $format = self::DATE_FORMAT_ISO8601;
|
44 |
+
|
45 |
+
private $specials = array(
|
46 |
+
'ISO8601' => self::DATE_FORMAT_ISO8601,
|
47 |
+
'ABSOLUTE' => self::DATE_FORMAT_ABSOLUTE,
|
48 |
+
'DATE' => self::DATE_FORMAT_DATE,
|
49 |
+
);
|
50 |
+
|
51 |
+
private $useLocalDate = false;
|
52 |
+
|
53 |
+
public function activateOptions() {
|
54 |
+
|
55 |
+
// Parse the option (date format)
|
56 |
+
if (!empty($this->option)) {
|
57 |
+
if(isset($this->specials[$this->option])) {
|
58 |
+
$this->format = $this->specials[$this->option];
|
59 |
+
} else {
|
60 |
+
$this->format = $this->option;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
// Check whether the pattern contains milliseconds (u)
|
65 |
+
if (preg_match('/(?<!\\\\)u/', $this->format)) {
|
66 |
+
$this->useLocalDate = true;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
public function convert(LoggerLoggingEvent $event) {
|
71 |
+
if ($this->useLocalDate) {
|
72 |
+
return $this->date($this->format, $event->getTimeStamp());
|
73 |
+
}
|
74 |
+
return date($this->format, $event->getTimeStamp());
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Currently, PHP date() function always returns zeros for milliseconds (u)
|
79 |
+
* on Windows. This is a replacement function for date() which correctly
|
80 |
+
* displays milliseconds on all platforms.
|
81 |
+
*
|
82 |
+
* It is slower than PHP date() so it should only be used if necessary.
|
83 |
+
*/
|
84 |
+
private function date($format, $utimestamp) {
|
85 |
+
$timestamp = floor($utimestamp);
|
86 |
+
$ms = floor(($utimestamp - $timestamp) * 1000);
|
87 |
+
$ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
|
88 |
+
|
89 |
+
return date(preg_replace('`(?<!\\\\)u`', $ms, $format), $timestamp);
|
90 |
+
}
|
91 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterEnvironment.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns a value from the $_ENV superglobal array corresponding to the
|
23 |
+
* given key.
|
24 |
+
*
|
25 |
+
* Options:
|
26 |
+
* [0] $_ENV key value
|
27 |
+
*
|
28 |
+
* @package log4php
|
29 |
+
* @subpackage pattern
|
30 |
+
* @version $Revision: 1326626 $
|
31 |
+
* @since 2.3
|
32 |
+
*/
|
33 |
+
class LoggerPatternConverterEnvironment extends LoggerPatternConverterSuperglobal {
|
34 |
+
protected $name = '_ENV';
|
35 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterFile.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the name of the file from which the logging request was issued.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1326626 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterFile extends LoggerPatternConverter {
|
30 |
+
|
31 |
+
public function convert(LoggerLoggingEvent $event) {
|
32 |
+
return $event->getLocationInformation()->getFileName();
|
33 |
+
}
|
34 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterLevel.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the event's level.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1326626 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterLevel extends LoggerPatternConverter {
|
30 |
+
|
31 |
+
public function convert(LoggerLoggingEvent $event) {
|
32 |
+
return $event->getLevel()->toString();
|
33 |
+
}
|
34 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterLine.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the line number within the file from which the logging request was
|
23 |
+
* issued.
|
24 |
+
*
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage pattern
|
27 |
+
* @version $Revision: 1326626 $
|
28 |
+
* @since 2.3
|
29 |
+
*/
|
30 |
+
class LoggerPatternConverterLine extends LoggerPatternConverter {
|
31 |
+
|
32 |
+
public function convert(LoggerLoggingEvent $event) {
|
33 |
+
return $event->getLocationInformation()->getLineNumber();
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerClassNamePatternConverter.php → lib/Log4php/pattern/LoggerPatternConverterLiteral.php
RENAMED
@@ -1,45 +1,40 @@
|
|
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 |
-
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
public function __construct($
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
public function getFullyQualifiedName($event) {
|
42 |
-
return $event->getFullQualifiedClassname();
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
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 |
+
/**
|
22 |
+
* Returns the literal value passed in the constructor, without modifications.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1326626 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterLiteral extends LoggerPatternConverter {
|
30 |
+
|
31 |
+
private $literalValue;
|
32 |
+
|
33 |
+
public function __construct($literalValue) {
|
34 |
+
$this->literalValue = $literalValue;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function convert(LoggerLoggingEvent $event) {
|
38 |
+
return $this->literalValue;
|
39 |
+
}
|
40 |
+
}
|
|
|
|
|
|
|
|
|
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerLiteralPatternConverter.php → lib/Log4php/pattern/LoggerPatternConverterLocation.php
RENAMED
@@ -1,57 +1,39 @@
|
|
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 |
-
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @param string &$sbuf
|
43 |
-
* @param LoggerLoggingEvent $event
|
44 |
-
*/
|
45 |
-
public function format(&$sbuf, $event) {
|
46 |
-
$sbuf .= $this->literal;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* @param LoggerLoggingEvent $event
|
51 |
-
* @return string
|
52 |
-
*/
|
53 |
-
public function convert($event) {
|
54 |
-
return $this->literal;
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
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 |
+
/**
|
22 |
+
* Returns the line number within the file from which the logging request was
|
23 |
+
* issued.
|
24 |
+
*
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage pattern
|
27 |
+
* @version $Revision: 1326626 $
|
28 |
+
* @since 2.3
|
29 |
+
*/
|
30 |
+
class LoggerPatternConverterLocation extends LoggerPatternConverter {
|
31 |
+
|
32 |
+
public function convert(LoggerLoggingEvent $event) {
|
33 |
+
return
|
34 |
+
$event->getLocationInformation()->getClassName() . '.' .
|
35 |
+
$event->getLocationInformation()->getMethodName() . '(' .
|
36 |
+
$event->getLocationInformation()->getFileName() . ':' .
|
37 |
+
$event->getLocationInformation()->getLineNumber() . ')';
|
38 |
+
}
|
39 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Log4php/pattern/LoggerPatternConverterLogger.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the name of the logger which created the logging request.
|
23 |
+
*
|
24 |
+
* Takes one option, which is an integer. If the option is given, the logger
|
25 |
+
* name will be shortened to the given length, if possible.
|
26 |
+
*
|
27 |
+
* @package log4php
|
28 |
+
* @subpackage pattern
|
29 |
+
* @version $Revision: 1326626 $
|
30 |
+
* @since 2.3
|
31 |
+
*/
|
32 |
+
class LoggerPatternConverterLogger extends LoggerPatternConverter {
|
33 |
+
|
34 |
+
/** Length to which to shorten the name. */
|
35 |
+
private $length;
|
36 |
+
|
37 |
+
/** Holds processed logger names. */
|
38 |
+
private $cache = array();
|
39 |
+
|
40 |
+
public function activateOptions() {
|
41 |
+
// Parse the option (desired output length)
|
42 |
+
if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
|
43 |
+
$this->length = (integer) $this->option;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
public function convert(LoggerLoggingEvent $event) {
|
48 |
+
$name = $event->getLoggerName();
|
49 |
+
|
50 |
+
if (!isset($this->cache[$name])) {
|
51 |
+
|
52 |
+
// If length is set return shortened logger name
|
53 |
+
if (isset($this->length)) {
|
54 |
+
$this->cache[$name] = LoggerUtils::shortenClassName($name, $this->length);
|
55 |
+
}
|
56 |
+
|
57 |
+
// If no length is specified return full logger name
|
58 |
+
else {
|
59 |
+
$this->cache[$name] = $name;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
return $this->cache[$name];
|
64 |
+
}
|
65 |
+
}
|
app/code/community/Nmmlm/Log/log4php/renderers/LoggerRendererDefault.php → lib/Log4php/pattern/LoggerPatternConverterMDC.php
RENAMED
@@ -1,51 +1,55 @@
|
|
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 |
-
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the Mapped Diagnostic Context value corresponding to the given key.
|
23 |
+
*
|
24 |
+
* Options:
|
25 |
+
* [0] the MDC key
|
26 |
+
*
|
27 |
+
* @package log4php
|
28 |
+
* @subpackage pattern
|
29 |
+
* @version $Revision: 1326626 $
|
30 |
+
* @since 2.3
|
31 |
+
*/
|
32 |
+
class LoggerPatternConverterMDC extends LoggerPatternConverter {
|
33 |
+
|
34 |
+
private $key;
|
35 |
+
|
36 |
+
public function activateOptions() {
|
37 |
+
if (isset($this->option) && $this->option !== '') {
|
38 |
+
$this->key = $this->option;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
public function convert(LoggerLoggingEvent $event) {
|
43 |
+
if (isset($this->key)) {
|
44 |
+
return $event->getMDC($this->key);
|
45 |
+
} else {
|
46 |
+
$buff = array();
|
47 |
+
$map = $event->getMDCMap();
|
48 |
+
foreach($map as $key => $value) {
|
49 |
+
$buff []= "$key=$value";
|
50 |
+
}
|
51 |
+
return implode(', ', $buff);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
lib/Log4php/pattern/LoggerPatternConverterMessage.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the logged message.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1326626 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterMessage extends LoggerPatternConverter {
|
30 |
+
|
31 |
+
public function convert(LoggerLoggingEvent $event) {
|
32 |
+
return $event->getRenderedMessage();
|
33 |
+
}
|
34 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterMethod.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the name of the function or method from which the logging request
|
23 |
+
* was issued.
|
24 |
+
*
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage pattern
|
27 |
+
* @version $Revision: 1326626 $
|
28 |
+
* @since 2.3
|
29 |
+
*/
|
30 |
+
class LoggerPatternConverterMethod extends LoggerPatternConverter {
|
31 |
+
|
32 |
+
public function convert(LoggerLoggingEvent $event) {
|
33 |
+
return $event->getLocationInformation()->getMethodName();
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerMDCPatternConverter.php → lib/Log4php/pattern/LoggerPatternConverterNDC.php
RENAMED
@@ -1,50 +1,35 @@
|
|
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 |
-
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
* @param string $key
|
37 |
-
*/
|
38 |
-
public function __construct($formattingInfo, $key) {
|
39 |
-
parent::__construct($formattingInfo);
|
40 |
-
$this->key = $key;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @param LoggerLoggingEvent $event
|
45 |
-
* @return string
|
46 |
-
*/
|
47 |
-
public function convert($event) {
|
48 |
-
return $event->getMDC($this->key);
|
49 |
-
}
|
50 |
-
}
|
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 |
+
/**
|
22 |
+
* Returns the full Nested Diagnostic Context.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1326626 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterNDC extends LoggerPatternConverter {
|
30 |
+
|
31 |
+
public function convert(LoggerLoggingEvent $event) {
|
32 |
+
return $event->getNDC();
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Log4php/pattern/LoggerPatternConverterNewLine.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns platform-specific newline character(s).
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1326626 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterNewLine extends LoggerPatternConverter {
|
30 |
+
|
31 |
+
public function convert(LoggerLoggingEvent $event) {
|
32 |
+
return PHP_EOL;
|
33 |
+
}
|
34 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterProcess.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the PID of the current process.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1326626 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterProcess extends LoggerPatternConverter {
|
30 |
+
|
31 |
+
public function convert(LoggerLoggingEvent $event) {
|
32 |
+
return getmypid();
|
33 |
+
}
|
34 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterRelative.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the number of milliseconds elapsed since the start of the
|
23 |
+
* application until the creation of the logging event.
|
24 |
+
*
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage pattern
|
27 |
+
* @version $Revision: 1379731 $
|
28 |
+
* @since 2.3
|
29 |
+
*/
|
30 |
+
class LoggerPatternConverterRelative extends LoggerPatternConverter {
|
31 |
+
|
32 |
+
public function convert(LoggerLoggingEvent $event) {
|
33 |
+
$ts = $event->getRelativeTime();
|
34 |
+
return number_format($ts, 4);
|
35 |
+
}
|
36 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterRequest.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns a value from the $_REQUEST superglobal array corresponding to the
|
23 |
+
* given key.
|
24 |
+
*
|
25 |
+
* Options:
|
26 |
+
* [0] $_REQUEST key value
|
27 |
+
*
|
28 |
+
* @package log4php
|
29 |
+
* @subpackage pattern
|
30 |
+
* @version $Revision: 1326626 $
|
31 |
+
* @since 2.3
|
32 |
+
*/
|
33 |
+
class LoggerPatternConverterRequest extends LoggerPatternConverterSuperglobal {
|
34 |
+
protected $name = '_REQUEST';
|
35 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterServer.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns a value from the $_SERVER superglobal array corresponding to the
|
23 |
+
* given key.
|
24 |
+
*
|
25 |
+
* Options:
|
26 |
+
* [0] $_SERVER key value
|
27 |
+
*
|
28 |
+
* @package log4php
|
29 |
+
* @subpackage pattern
|
30 |
+
* @version $Revision: 1326626 $
|
31 |
+
* @since 2.3
|
32 |
+
*/
|
33 |
+
class LoggerPatternConverterServer extends LoggerPatternConverterSuperglobal {
|
34 |
+
protected $name = '_SERVER';
|
35 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterSession.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns a value from the $_SESSION superglobal array corresponding to the
|
23 |
+
* given key.
|
24 |
+
*
|
25 |
+
* Options:
|
26 |
+
* [0] $_SESSION key value
|
27 |
+
*
|
28 |
+
* @package log4php
|
29 |
+
* @subpackage pattern
|
30 |
+
* @version $Revision: 1326626 $
|
31 |
+
* @since 2.3
|
32 |
+
*/
|
33 |
+
class LoggerPatternConverterSession extends LoggerPatternConverterSuperglobal {
|
34 |
+
protected $name = '_SESSION';
|
35 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterSessionID.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the active session ID, or an empty string if out of session.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1326626 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterSessionID extends LoggerPatternConverter {
|
30 |
+
public function convert(LoggerLoggingEvent $event) {
|
31 |
+
return session_id();
|
32 |
+
}
|
33 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterSuperglobal.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns a value from a superglobal array corresponding to the
|
23 |
+
* given key.
|
24 |
+
*
|
25 |
+
* Option: the key to look up within the superglobal array
|
26 |
+
*
|
27 |
+
* Also, it is possible that a superglobal variable is not populated by PHP
|
28 |
+
* because of the settings in the variables-order ini directive. In this case
|
29 |
+
* the converter will return an empty value.
|
30 |
+
*
|
31 |
+
* @see http://php.net/manual/en/language.variables.superglobals.php
|
32 |
+
* @see http://www.php.net/manual/en/ini.core.php#ini.variables-order
|
33 |
+
*
|
34 |
+
* @package log4php
|
35 |
+
* @subpackage pattern
|
36 |
+
* @version $Revision: 1326626 $
|
37 |
+
* @since 2.3
|
38 |
+
*/
|
39 |
+
abstract class LoggerPatternConverterSuperglobal extends LoggerPatternConverter {
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Name of the superglobal variable, to be defined by subclasses.
|
43 |
+
* For example: "_SERVER" or "_ENV".
|
44 |
+
*/
|
45 |
+
protected $name;
|
46 |
+
|
47 |
+
protected $value = '';
|
48 |
+
|
49 |
+
public function activateOptions() {
|
50 |
+
// Read the key from options array
|
51 |
+
if (isset($this->option) && $this->option !== '') {
|
52 |
+
$key = $this->option;
|
53 |
+
}
|
54 |
+
|
55 |
+
/*
|
56 |
+
* There is a bug in PHP which doesn't allow superglobals to be
|
57 |
+
* accessed when their name is stored in a variable, e.g.:
|
58 |
+
*
|
59 |
+
* $name = '_SERVER';
|
60 |
+
* $array = $$name;
|
61 |
+
*
|
62 |
+
* This code does not work when run from within a method (only when run
|
63 |
+
* in global scope). But the following code does work:
|
64 |
+
*
|
65 |
+
* $name = '_SERVER';
|
66 |
+
* global $$name;
|
67 |
+
* $array = $$name;
|
68 |
+
*
|
69 |
+
* That's why global is used here.
|
70 |
+
*/
|
71 |
+
global ${$this->name};
|
72 |
+
|
73 |
+
// Check the given superglobal exists. It is possible that it is not initialized.
|
74 |
+
if (!isset(${$this->name})) {
|
75 |
+
$class = get_class($this);
|
76 |
+
trigger_error("log4php: $class: Cannot find superglobal variable \${$this->name}.", E_USER_WARNING);
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
$source = ${$this->name};
|
81 |
+
|
82 |
+
// When the key is set, display the matching value
|
83 |
+
if (isset($key)) {
|
84 |
+
if (isset($source[$key])) {
|
85 |
+
$this->value = $source[$key];
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
// When the key is not set, display all values
|
90 |
+
else {
|
91 |
+
$values = array();
|
92 |
+
foreach($source as $key => $value) {
|
93 |
+
$values[] = "$key=$value";
|
94 |
+
}
|
95 |
+
$this->value = implode(', ', $values);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
public function convert(LoggerLoggingEvent $event) {
|
100 |
+
return $this->value;
|
101 |
+
}
|
102 |
+
}
|
lib/Log4php/pattern/LoggerPatternConverterThrowable.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Returns the throwable information linked to the logging event, if any.
|
23 |
+
*
|
24 |
+
* @package log4php
|
25 |
+
* @subpackage pattern
|
26 |
+
* @version $Revision: 1395470 $
|
27 |
+
* @since 2.3
|
28 |
+
*/
|
29 |
+
class LoggerPatternConverterThrowable extends LoggerPatternConverter {
|
30 |
+
|
31 |
+
public function convert(LoggerLoggingEvent $event) {
|
32 |
+
$info = $event->getThrowableInformation();
|
33 |
+
if (isset($info)) {
|
34 |
+
$ex = $info->getThrowable();
|
35 |
+
return (string) $ex . PHP_EOL;
|
36 |
+
}
|
37 |
+
return '';
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
app/code/community/Nmmlm/Log/log4php/helpers/LoggerCategoryPatternConverter.php → lib/Log4php/renderers/LoggerRenderer.php
RENAMED
@@ -1,44 +1,36 @@
|
|
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 |
-
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
*
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @param LoggerLoggingEvent $event
|
39 |
-
* @return string
|
40 |
-
*/
|
41 |
-
public function getFullyQualifiedName($event) {
|
42 |
-
return $event->getLoggerName();
|
43 |
-
}
|
44 |
-
}
|
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 |
+
/**
|
22 |
+
* Implement this interface in order to render objects to strings.
|
23 |
+
*
|
24 |
+
* @version $Revision: 1394956 $
|
25 |
+
* @package log4php
|
26 |
+
* @subpackage renderers
|
27 |
+
* @since 0.3
|
28 |
+
*/
|
29 |
+
interface LoggerRenderer {
|
30 |
+
/**
|
31 |
+
* Renders the entity passed as <var>input</var> to a string.
|
32 |
+
* @param mixed $input The entity to render.
|
33 |
+
* @return string The rendered string.
|
34 |
+
*/
|
35 |
+
public function render($input);
|
36 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Log4php/renderers/LoggerRendererDefault.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* The default renderer, which is used when no other renderer is found.
|
23 |
+
*
|
24 |
+
* Renders the input using <var>print_r</var>.
|
25 |
+
*
|
26 |
+
* @package log4php
|
27 |
+
* @subpackage renderers
|
28 |
+
* @since 0.3
|
29 |
+
*/
|
30 |
+
class LoggerRendererDefault implements LoggerRenderer {
|
31 |
+
|
32 |
+
/** @inheritdoc */
|
33 |
+
public function render($input) {
|
34 |
+
return print_r($input, true);
|
35 |
+
}
|
36 |
+
}
|
{app/code/community/Nmmlm/Log/log4php → lib/Log4php}/renderers/LoggerRendererException.php
RENAMED
@@ -19,23 +19,18 @@
|
|
19 |
*/
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
*
|
24 |
* @package log4php
|
25 |
* @subpackage renderers
|
26 |
* @since 2.1
|
27 |
*/
|
28 |
-
class LoggerRendererException implements
|
29 |
|
30 |
-
public function render($
|
31 |
-
$strRep = 'Throwable('.get_class($o).'): '.$o->getMessage().' in '.$o->getFile().' on line '.$o->getLine();
|
32 |
-
$strRep .= PHP_EOL.$o->getTraceAsString();
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
return $strRep;
|
39 |
}
|
40 |
}
|
41 |
-
?>
|
19 |
*/
|
20 |
|
21 |
/**
|
22 |
+
* Renderer used for Exceptions.
|
23 |
*
|
24 |
* @package log4php
|
25 |
* @subpackage renderers
|
26 |
* @since 2.1
|
27 |
*/
|
28 |
+
class LoggerRendererException implements LoggerRenderer {
|
29 |
|
30 |
+
public function render($input) {
|
|
|
|
|
31 |
|
32 |
+
// Exception class has a very decent __toString method
|
33 |
+
// so let's just use that instead of writing lots of code.
|
34 |
+
return (string) $input;
|
|
|
|
|
35 |
}
|
36 |
}
|
|
lib/Log4php/renderers/LoggerRendererMap.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/**
|
22 |
+
* Manages defined renderers and determines which renderer to use for a given
|
23 |
+
* input.
|
24 |
+
*
|
25 |
+
* @version $Revision: 1394956 $
|
26 |
+
* @package log4php
|
27 |
+
* @subpackage renderers
|
28 |
+
* @since 0.3
|
29 |
+
*/
|
30 |
+
class LoggerRendererMap {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Maps class names to appropriate renderers.
|
34 |
+
* @var array
|
35 |
+
*/
|
36 |
+
private $map = array();
|
37 |
+
|
38 |
+
/**
|
39 |
+
* The default renderer to use if no specific renderer is found.
|
40 |
+
* @var LoggerRenderer
|
41 |
+
*/
|
42 |
+
private $defaultRenderer;
|
43 |
+
|
44 |
+
public function __construct() {
|
45 |
+
|
46 |
+
// Set default config
|
47 |
+
$this->reset();
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Adds a renderer to the map.
|
52 |
+
*
|
53 |
+
* If a renderer already exists for the given <var>$renderedClass</var> it
|
54 |
+
* will be overwritten without warning.
|
55 |
+
*
|
56 |
+
* @param string $renderedClass The name of the class which will be
|
57 |
+
* rendered by the renderer.
|
58 |
+
* @param string $renderingClass The name of the class which will
|
59 |
+
* perform the rendering.
|
60 |
+
*/
|
61 |
+
public function addRenderer($renderedClass, $renderingClass) {
|
62 |
+
// Check the rendering class exists
|
63 |
+
if (!class_exists($renderingClass)) {
|
64 |
+
trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.");
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
// Create the instance
|
69 |
+
$renderer = new $renderingClass();
|
70 |
+
|
71 |
+
// Check the class implements the right interface
|
72 |
+
if (!($renderer instanceof LoggerRenderer)) {
|
73 |
+
trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the LoggerRenderer interface.");
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
// Convert to lowercase since class names in PHP are not case sensitive
|
78 |
+
$renderedClass = strtolower($renderedClass);
|
79 |
+
|
80 |
+
$this->map[$renderedClass] = $renderer;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Sets a custom default renderer class.
|
85 |
+
*
|
86 |
+
* TODO: there's code duplication here. This method is almost identical to
|
87 |
+
* addRenderer(). However, it has custom error messages so let it sit for
|
88 |
+
* now.
|
89 |
+
*
|
90 |
+
* @param string $renderingClass The name of the class which will
|
91 |
+
* perform the rendering.
|
92 |
+
*/
|
93 |
+
public function setDefaultRenderer($renderingClass) {
|
94 |
+
// Check the class exists
|
95 |
+
if (!class_exists($renderingClass)) {
|
96 |
+
trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.");
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
|
100 |
+
// Create the instance
|
101 |
+
$renderer = new $renderingClass();
|
102 |
+
|
103 |
+
// Check the class implements the right interface
|
104 |
+
if (!($renderer instanceof LoggerRenderer)) {
|
105 |
+
trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the LoggerRenderer interface.");
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
|
109 |
+
$this->defaultRenderer = $renderer;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Returns the default renderer.
|
114 |
+
* @var LoggerRenderer
|
115 |
+
*/
|
116 |
+
public function getDefaultRenderer() {
|
117 |
+
return $this->defaultRenderer;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Finds the appropriate renderer for the given <var>input</var>, and
|
122 |
+
* renders it (i.e. converts it to a string).
|
123 |
+
*
|
124 |
+
* @param mixed $input Input to render.
|
125 |
+
* @return string The rendered contents.
|
126 |
+
*/
|
127 |
+
public function findAndRender($input) {
|
128 |
+
if ($input === null) {
|
129 |
+
return null;
|
130 |
+
}
|
131 |
+
|
132 |
+
// For objects, try to find a renderer in the map
|
133 |
+
if(is_object($input)) {
|
134 |
+
$renderer = $this->getByClassName(get_class($input));
|
135 |
+
if (isset($renderer)) {
|
136 |
+
return $renderer->render($input);
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
// Fall back to the default renderer
|
141 |
+
return $this->defaultRenderer->render($input);
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Returns the appropriate renderer for a given object.
|
146 |
+
*
|
147 |
+
* @param mixed $object
|
148 |
+
* @return LoggerRenderer Or null if none found.
|
149 |
+
*/
|
150 |
+
public function getByObject($object) {
|
151 |
+
if (!is_object($object)) {
|
152 |
+
return null;
|
153 |
+
}
|
154 |
+
return $this->getByClassName(get_class($object));
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Returns the appropriate renderer for a given class name.
|
159 |
+
*
|
160 |
+
* If no renderer could be found, returns NULL.
|
161 |
+
*
|
162 |
+
* @param string $class
|
163 |
+
* @return LoggerRendererObject Or null if not found.
|
164 |
+
*/
|
165 |
+
public function getByClassName($class) {
|
166 |
+
for(; !empty($class); $class = get_parent_class($class)) {
|
167 |
+
$class = strtolower($class);
|
168 |
+
if(isset($this->map[$class])) {
|
169 |
+
return $this->map[$class];
|
170 |
+
}
|
171 |
+
}
|
172 |
+
return null;
|
173 |
+
}
|
174 |
+
|
175 |
+
/** Empties the renderer map. */
|
176 |
+
public function clear() {
|
177 |
+
$this->map = array();
|
178 |
+
}
|
179 |
+
|
180 |
+
/** Resets the renderer map to it's default configuration. */
|
181 |
+
public function reset() {
|
182 |
+
$this->defaultRenderer = new LoggerRendererDefault();
|
183 |
+
$this->clear();
|
184 |
+
$this->addRenderer('Exception', 'LoggerRendererException');
|
185 |
+
}
|
186 |
+
}
|
lib/Log4php/xml/log4php.dtd
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
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 |
+
<!-- Authors: Chris Taylor, Ceki Gülcü. -->
|
19 |
+
<!-- Version: 1.2 -->
|
20 |
+
|
21 |
+
<!-- PHP Port Modifications Author: Marco Vassura -->
|
22 |
+
<!-- PHP dtd Version: $Revision: 823875 $ -->
|
23 |
+
|
24 |
+
<!-- A configuration element consists of optional renderer
|
25 |
+
elements,appender elements, categories and an optional root
|
26 |
+
element. -->
|
27 |
+
<!-- [log4php] -->
|
28 |
+
<!--
|
29 |
+
category instead of logger cannot be used. categoryFactory is not implemented in log4php.
|
30 |
+
-->
|
31 |
+
<!-- [/log4php] -->
|
32 |
+
<!ELEMENT log4php:configuration (renderer*, appender*,(logger)*,root?)>
|
33 |
+
|
34 |
+
<!-- The "threshold" attribute takes a level value such that all -->
|
35 |
+
<!-- logging statements with a level equal or below this value are -->
|
36 |
+
<!-- disabled. -->
|
37 |
+
|
38 |
+
<!-- Setting the "debug" enable the printing of internal log4j logging -->
|
39 |
+
<!-- statements. -->
|
40 |
+
|
41 |
+
<!-- By default, debug attribute is "null", meaning that we not do touch -->
|
42 |
+
<!-- internal log4j logging settings. The "null" value for the threshold -->
|
43 |
+
<!-- attribute can be misleading. The threshold field of a repository -->
|
44 |
+
<!-- cannot be set to null. The "null" value for the threshold attribute -->
|
45 |
+
<!-- simply means don't touch the threshold field, the threshold field -->
|
46 |
+
<!-- keeps its old value. -->
|
47 |
+
|
48 |
+
<!ATTLIST log4php:configuration
|
49 |
+
xmlns:log4php CDATA #FIXED "http://logging.apache.org/log4php"
|
50 |
+
threshold (all|debug|info|warn|error|fatal|off|null) "null"
|
51 |
+
>
|
52 |
+
|
53 |
+
<!-- renderer elements allow the user to customize the conversion of -->
|
54 |
+
<!-- message objects to String. -->
|
55 |
+
<!ELEMENT renderer EMPTY>
|
56 |
+
<!ATTLIST renderer
|
57 |
+
renderedClass CDATA #REQUIRED
|
58 |
+
renderingClass CDATA #REQUIRED
|
59 |
+
>
|
60 |
+
|
61 |
+
<!-- Appenders must have a name and a class. -->
|
62 |
+
<!-- Appenders may contain an error handler, a layout, optional parameters -->
|
63 |
+
<!-- and filters. They may also reference (or include) other appenders. -->
|
64 |
+
<!-- [log4php] -->
|
65 |
+
<!-- error handler tag has no effects since log4php does not handle errors. Defintion deleted. -->
|
66 |
+
<!-- [/log4php] -->
|
67 |
+
<!ELEMENT appender (param*, layout?, filter*, appender-ref*)>
|
68 |
+
<!ATTLIST appender
|
69 |
+
name ID #REQUIRED
|
70 |
+
class CDATA #REQUIRED
|
71 |
+
>
|
72 |
+
|
73 |
+
<!ELEMENT layout (param*)>
|
74 |
+
<!ATTLIST layout
|
75 |
+
class CDATA #REQUIRED
|
76 |
+
>
|
77 |
+
|
78 |
+
<!ELEMENT filter (param*)>
|
79 |
+
<!ATTLIST filter
|
80 |
+
class CDATA #REQUIRED
|
81 |
+
>
|
82 |
+
|
83 |
+
|
84 |
+
<!ELEMENT param EMPTY>
|
85 |
+
<!ATTLIST param
|
86 |
+
name CDATA #REQUIRED
|
87 |
+
value CDATA #REQUIRED
|
88 |
+
>
|
89 |
+
|
90 |
+
<!ELEMENT priority EMPTY>
|
91 |
+
<!ATTLIST priority
|
92 |
+
value CDATA #REQUIRED
|
93 |
+
>
|
94 |
+
|
95 |
+
<!ELEMENT level EMPTY>
|
96 |
+
<!ATTLIST level
|
97 |
+
value CDATA #REQUIRED
|
98 |
+
>
|
99 |
+
|
100 |
+
<!-- If no level element is specified, then the configurator MUST not -->
|
101 |
+
<!-- touch the level of the named logger. -->
|
102 |
+
<!ELEMENT logger (level?,appender-ref*)>
|
103 |
+
<!ATTLIST logger
|
104 |
+
name ID #REQUIRED
|
105 |
+
additivity (true|false) "true"
|
106 |
+
>
|
107 |
+
|
108 |
+
<!ELEMENT appender-ref EMPTY>
|
109 |
+
<!ATTLIST appender-ref
|
110 |
+
ref IDREF #REQUIRED
|
111 |
+
>
|
112 |
+
|
113 |
+
<!-- If no priority element is specified, then the configurator MUST not -->
|
114 |
+
<!-- touch the priority of root. -->
|
115 |
+
<!-- The root category always exists and cannot be subclassed. -->
|
116 |
+
<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
|
117 |
+
|
118 |
+
|
119 |
+
<!-- ==================================================================== -->
|
120 |
+
<!-- A logging event -->
|
121 |
+
<!-- ==================================================================== -->
|
122 |
+
<!ELEMENT log4php:eventSet (log4php:event*)>
|
123 |
+
<!ATTLIST log4php:eventSet
|
124 |
+
xmlns:log4php CDATA #FIXED "http://www.vxr.it/log4php/"
|
125 |
+
version (0.2|0.3) "0.3"
|
126 |
+
includesLocationInfo (true|false) "true"
|
127 |
+
>
|
128 |
+
|
129 |
+
<!ELEMENT log4php:event (log4php:message, log4php:locationInfo?) >
|
130 |
+
|
131 |
+
<!-- The timestamp format is application dependent. -->
|
132 |
+
<!ATTLIST log4php:event
|
133 |
+
logger CDATA #REQUIRED
|
134 |
+
level CDATA #REQUIRED
|
135 |
+
thread CDATA #REQUIRED
|
136 |
+
timestamp CDATA #REQUIRED
|
137 |
+
>
|
138 |
+
|
139 |
+
<!ELEMENT log4php:message (#PCDATA)>
|
140 |
+
<!ELEMENT log4php:NDC (#PCDATA)>
|
141 |
+
|
142 |
+
<!ELEMENT log4php:locationInfo EMPTY>
|
143 |
+
<!ATTLIST log4php:locationInfo
|
144 |
+
class CDATA #REQUIRED
|
145 |
+
method CDATA #REQUIRED
|
146 |
+
file CDATA #REQUIRED
|
147 |
+
line CDATA #REQUIRED
|
148 |
+
>
|
package.xml
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>nmmlm_log</name>
|
4 |
-
<version>0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/apachepl.php">Apache Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Magento wrapper for Apache log4php logging framework. This logger adds flexible control to your logs.</summary>
|
10 |
<description>All the power of Apache Log4php Logging Framework now available for Magento developers courtesy of Praxigento. Take full control over your logging output. Eliminate all irrelevant information from your logs or get as much details as you need. Setup logging level and output files for different PHP classes on the fly. Easy configuration through XML config file.</description>
|
11 |
-
<notes
|
|
|
|
|
12 |
<authors><author><name>Alex</name><user>Gusev</user><email>alex@nmmlm.com</email></author></authors>
|
13 |
-
<date>2012-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Nmmlm"><dir name="Log"><file name="Logger.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>nmmlm_log</name>
|
4 |
+
<version>0.3.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/apachepl.php">Apache Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Magento wrapper for Apache log4php logging framework. This logger adds flexible control to your logs.</summary>
|
10 |
<description>All the power of Apache Log4php Logging Framework now available for Magento developers courtesy of Praxigento. Take full control over your logging output. Eliminate all irrelevant information from your logs or get as much details as you need. Setup logging level and output files for different PHP classes on the fly. Easy configuration through XML config file.</description>
|
11 |
+
<notes>Release 0.3.0 (2012/12/12):
|
12 |
+
- Log4php library is updated to version 2.3.0;
|
13 |
+
- Log4php library is moved to '/lib' folder;</notes>
|
14 |
<authors><author><name>Alex</name><user>Gusev</user><email>alex@nmmlm.com</email></author></authors>
|
15 |
+
<date>2012-12-12</date>
|
16 |
+
<time>20:12:52</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Nmmlm"><dir name="Log"><file name="Logger.php" hash="e6183dc5dff44f51aaba4f311fcacee0"/><file name="Util.php" hash="ef65a2a7b00c2100aa1da5015b2a4274"/><dir name="etc"><file name="config.xml" hash="eddb7289d63099c91a2f30440d20b408"/><file name="release.txt" hash="6640546a7a9e01e5e85e8d15184db1ca"/><file name="system.xml" hash="20b82c329b8da21c3a6243397bf6cc99"/></dir></dir></dir></target><target name="mageetc"><dir name="nmmlm"><dir name="log"><file name="log4php.cfg.xml" hash="7ec24d730932c9fa45d16c005f73f382"/></dir></dir><dir name="modules"><file name="Nmmlm_Log.xml" hash="51d31dde4f296b9207ef6d7b8ed897d6"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="nmmlm"><dir name="log"><file name="Nmmlm_Log.csv" hash="5a5cbb4f9d8e6d1887cc78fe91c2d401"/></dir></dir></dir><dir name="ru_RU"><dir name="nmmlm"><dir name="log"><file name="Nmmlm_Log.csv" hash="56317cedf682d0a0877efc88a3aa5ee9"/></dir></dir></dir></target><target name="magelib"><dir name="Log4php"><file name="Logger.php" hash="2c8e3775c118e0d1facdc3eb3c79ac7f"/><file name="LoggerAppender.php" hash="7472cea381000c30dcefc6d238ced868"/><file name="LoggerAppenderPool.php" hash="7e44ee58fbd3c50ae51c98742aa4f327"/><file name="LoggerAutoloader.php" hash="482fefc440d94dc9307e4e1cfde1b4a0"/><file name="LoggerConfigurable.php" hash="33a1d9b136c6ec12694118f76cc1d384"/><file name="LoggerConfigurator.php" hash="9d9716beeeb10cf2545dd1ddff470549"/><file name="LoggerException.php" hash="dd5d50aa3d6c0e8bd572b2dbcc9b42a7"/><file name="LoggerFilter.php" hash="bd24dad4974c2c387401c78923e78a0d"/><file name="LoggerHierarchy.php" hash="7f48959f121fb7952aa1a24dead8f08c"/><file name="LoggerLayout.php" hash="de88ba903999586d7a7348a9f225039e"/><file name="LoggerLevel.php" hash="2d22d6410640bcb353a0ff4c62568cd7"/><file name="LoggerLocationInfo.php" hash="3e9645e7cf6f917b867260f6147e0b06"/><file name="LoggerLoggingEvent.php" hash="4b2ec5be0037951bebd87c640c3fefab"/><file name="LoggerMDC.php" hash="aea4e702212d9ca6d768de47022cdb40"/><file name="LoggerNDC.php" hash="ecc1f1cc3ff4fb130d64ad2d8066287d"/><file name="LoggerReflectionUtils.php" hash="925f051e0515ed8f22b433456c92bf2f"/><file name="LoggerRoot.php" hash="405825189a51ffefd5b19e85b25a5bfb"/><file name="LoggerThrowableInformation.php" hash="76d98d20d55cf0e3bd4b1b138023c3af"/><dir name="appenders"><file name="LoggerAppenderConsole.php" hash="e7959ca32796cb4e49d97bd95a702391"/><file name="LoggerAppenderDailyFile.php" hash="9edd7cd0648c9d0b9bde18d669a36db7"/><file name="LoggerAppenderEcho.php" hash="598e88ae25e133ab1eb6cce16cc37488"/><file name="LoggerAppenderFile.php" hash="216ae0c735e19734e363919816771a1d"/><file name="LoggerAppenderFirePHP.php" hash="1eccdf817ff2e0204265a5a77901f0a1"/><file name="LoggerAppenderMail.php" hash="4ff5338965ee2654c52be96e74916d1d"/><file name="LoggerAppenderMailEvent.php" hash="363e4eff8adf5fb97a56ed201d0bdca8"/><file name="LoggerAppenderMemory.php" hash="ed7f776469de3a16432d95a2dfc9128d"/><file name="LoggerAppenderMongoDB.php" hash="70c0ab1962147326b1b2dd5b926a81c5"/><file name="LoggerAppenderNull.php" hash="14d181ef9b89f4bfb460f3e15a40636a"/><file name="LoggerAppenderPDO.php" hash="f86b4df252d3f0de8605976c2858f1ee"/><file name="LoggerAppenderPhp.php" hash="76cacd77fde78da3d593efeae884d0a7"/><file name="LoggerAppenderRollingFile.php" hash="6f0f77bc86073a921519b17fbe354809"/><file name="LoggerAppenderSocket.php" hash="8511283ecc096b8c9d74343b1cdd7d47"/><file name="LoggerAppenderSyslog.php" hash="7a1005f0eb90d80ca8faeca5a5765f6c"/></dir><dir name="configurators"><file name="LoggerConfigurationAdapter.php" hash="d0b815505f6c683520836e9458ca5d9f"/><file name="LoggerConfigurationAdapterINI.php" hash="a6ba019de49f5eef7db9e91583d34b37"/><file name="LoggerConfigurationAdapterPHP.php" hash="97665931be3ba4b42cc2b4bf9c8fac57"/><file name="LoggerConfigurationAdapterXML.php" hash="42ec1e713dadb1c6c813df278e6c58cb"/><file name="LoggerConfiguratorDefault.php" hash="4e861d03c50ec7ea213d7f9ebd461418"/></dir><dir name="filters"><file name="LoggerFilterDenyAll.php" hash="e9032bfeafd37be7afab2adf5c060626"/><file name="LoggerFilterLevelMatch.php" hash="12b27d1968866c19f13287164b449ab7"/><file name="LoggerFilterLevelRange.php" hash="cf1b0bf4ce01cb515053bd468bb50cd0"/><file name="LoggerFilterStringMatch.php" hash="c2bbb1b2a06a51b51d9f845cd5ebb6c8"/></dir><dir name="helpers"><file name="LoggerFormattingInfo.php" hash="c254fa1971dcf0fd2ecac28de3fc0bcb"/><file name="LoggerOptionConverter.php" hash="39d1d2c635338fbd75f33df554fda1e5"/><file name="LoggerPatternParser.php" hash="1f2e7cc7cc9497d0a99a83f83982205e"/><file name="LoggerUtils.php" hash="3b508c959bac95249510e5c0f7c0e213"/></dir><dir name="layouts"><file name="LoggerLayoutHtml.php" hash="f7fd23781e629d6429af79037e98470d"/><file name="LoggerLayoutPattern.php" hash="30d2ff33d27fb39adfe223bf3b6376b9"/><file name="LoggerLayoutSerialized.php" hash="26c100171dc9387a39466cedcad09fd9"/><file name="LoggerLayoutSimple.php" hash="77c0cf122c30b986e735b2ebe3be8870"/><file name="LoggerLayoutTTCC.php" hash="ccc042a97ae2a83cc72d997e2cf2cb74"/><file name="LoggerLayoutXml.php" hash="485d7cd523b55b1489c0eabe43b10a4d"/></dir><dir name="pattern"><file name="LoggerPatternConverter.php" hash="9b123620d6f67d73a1ed7d5debb274d9"/><file name="LoggerPatternConverterClass.php" hash="11e3bec4b974b71f491c77c743eaf448"/><file name="LoggerPatternConverterCookie.php" hash="f2259d111bcac3dfaa5ba9aceacb767f"/><file name="LoggerPatternConverterDate.php" hash="ec17f3613f1652eae5dd66e6a4adb3c8"/><file name="LoggerPatternConverterEnvironment.php" hash="66d35035f21eadd59df1952ee9d0a12a"/><file name="LoggerPatternConverterFile.php" hash="6be22538d2b26d7fc51dcf93026910d7"/><file name="LoggerPatternConverterLevel.php" hash="b072692d16da1f32f1e5e0297fbf7418"/><file name="LoggerPatternConverterLine.php" hash="8569326c777823b8d18a17a462ba77c8"/><file name="LoggerPatternConverterLiteral.php" hash="3ae068c09af6947cf5893b1e218a6b77"/><file name="LoggerPatternConverterLocation.php" hash="47c9d56031c777ad63f242d7586183d4"/><file name="LoggerPatternConverterLogger.php" hash="3fb15fe8622a592a6287d966fff2b6fc"/><file name="LoggerPatternConverterMDC.php" hash="18a3b621f15e0b7c4edfe08fd86dc7cf"/><file name="LoggerPatternConverterMessage.php" hash="cd1a2eaad13357ea81dd5f65deeace4c"/><file name="LoggerPatternConverterMethod.php" hash="7f01cd78cd4c2413dc05b8e5194e02c3"/><file name="LoggerPatternConverterNDC.php" hash="de55b0b1e022d77c1a491e17c0022ec1"/><file name="LoggerPatternConverterNewLine.php" hash="7c3fe93e6a6e4415484155128083b92b"/><file name="LoggerPatternConverterProcess.php" hash="5bb78006b0d2258db8322c58028d5475"/><file name="LoggerPatternConverterRelative.php" hash="3e192f9783728860923bda9a0cdeedb3"/><file name="LoggerPatternConverterRequest.php" hash="27c293f122d3eb57f63c7d3e7e42e771"/><file name="LoggerPatternConverterServer.php" hash="29ac58f17a8724806dc6083771946969"/><file name="LoggerPatternConverterSession.php" hash="68a3c312d9fa0c1b29dc485567c5d954"/><file name="LoggerPatternConverterSessionID.php" hash="4ec25f49d430b2582803b1a3886dbaa3"/><file name="LoggerPatternConverterSuperglobal.php" hash="9611fdf2a97789724b52a0d570d27602"/><file name="LoggerPatternConverterThrowable.php" hash="7069ed8401e5826c387b31c392906f9f"/></dir><dir name="renderers"><file name="LoggerRenderer.php" hash="89b10998ba64095e7c9ece4813d3529d"/><file name="LoggerRendererDefault.php" hash="fce33335182a5e5a6c85442a7624be2f"/><file name="LoggerRendererException.php" hash="4b2def2de9aa459bd321e826c02e31c2"/><file name="LoggerRendererMap.php" hash="149348daa8f34cb37b9ade92fce93c49"/></dir><dir name="xml"><file name="log4php.dtd" hash="7a8c05e23b9537a64249192aa56e74f2"/></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|