You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by ku...@apache.org on 2009/05/03 09:52:47 UTC
svn commit: r771037 - in /incubator/log4php/trunk/src/main/php: config/
helpers/ or/ spi/
Author: kurdalen
Date: Sun May 3 07:52:46 2009
New Revision: 771037
URL: http://svn.apache.org/viewvc?rev=771037&view=rev
Log:
code style fixes
Modified:
incubator/log4php/trunk/src/main/php/config/LoggerPropertyGetter.php
incubator/log4php/trunk/src/main/php/config/LoggerPropertySetter.php
incubator/log4php/trunk/src/main/php/helpers/LoggerFormattingInfo.php
incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php
incubator/log4php/trunk/src/main/php/or/LoggerDefaultRenderer.php
incubator/log4php/trunk/src/main/php/or/LoggerObjectRenderer.php
incubator/log4php/trunk/src/main/php/or/LoggerRendererMap.php
incubator/log4php/trunk/src/main/php/spi/LoggerConfigurator.php
incubator/log4php/trunk/src/main/php/spi/LoggerFactory.php
incubator/log4php/trunk/src/main/php/spi/LoggerFilter.php
Modified: incubator/log4php/trunk/src/main/php/config/LoggerPropertyGetter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/config/LoggerPropertyGetter.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/config/LoggerPropertyGetter.php (original)
+++ incubator/log4php/trunk/src/main/php/config/LoggerPropertyGetter.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Modified: incubator/log4php/trunk/src/main/php/config/LoggerPropertySetter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/config/LoggerPropertySetter.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/config/LoggerPropertySetter.php (original)
+++ incubator/log4php/trunk/src/main/php/config/LoggerPropertySetter.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -24,7 +24,7 @@
* General purpose Object property setter. Clients repeatedly invokes
* {@link setProperty()} in order to invoke setters
* on the Object specified in the constructor.
- *
+ *
* Usage:
* <code>
* $ps = new LoggerPropertySetter($anObject);
@@ -39,7 +39,7 @@
* $anObject->setMale(true)
* </code>
* if such methods exist.
- *
+ *
* @version $Revision$
* @package log4php
* @subpackage config
@@ -47,108 +47,106 @@
*/
class LoggerPropertySetter {
- /**
- * @var object the target object
- * @access private
- */
- var $obj;
+ /**
+ * @var object the target object
+ * @access private
+ */
+ var $obj;
- /**
- * Create a new LoggerPropertySetter for the specified Object.
- * This is done in prepartion for invoking {@link setProperty()}
- * one or more times.
- * @param object &$obj the object for which to set properties
- */
- function LoggerPropertySetter(&$obj)
- {
- $this->obj =& $obj;
- }
+ /**
+ * Create a new LoggerPropertySetter for the specified Object.
+ * This is done in prepartion for invoking {@link setProperty()}
+ * one or more times.
+ * @param object &$obj the object for which to set properties
+ */
+ function LoggerPropertySetter(&$obj) {
+ $this->obj =& $obj;
+ }
- /**
- * Set the properties of an object passed as a parameter in one
- * go. The <code>properties</code> are parsed relative to a
- * <code>prefix</code>.
- *
- * @param object &$obj The object to configure.
- * @param array $properties An array containing keys and values.
- * @param string $prefix Only keys having the specified prefix will be set.
- * @static
- */
- public static function setPropertiesByObject(&$obj, $properties, $prefix)
- {
- $pSetter = new LoggerPropertySetter($obj);
- return $pSetter->setProperties($properties, $prefix);
- }
+ /**
+ * Set the properties of an object passed as a parameter in one
+ * go. The <code>properties</code> are parsed relative to a
+ * <code>prefix</code>.
+ *
+ * @param object &$obj The object to configure.
+ * @param array $properties An array containing keys and values.
+ * @param string $prefix Only keys having the specified prefix will be set.
+ * @static
+ */
+ public static function setPropertiesByObject(&$obj, $properties, $prefix) {
+ $pSetter = new LoggerPropertySetter($obj);
+ return $pSetter->setProperties($properties, $prefix);
+ }
- /**
- * Set the properites for the object that match the
- * <code>prefix</code> passed as parameter.
- *
- * @param array $properties An array containing keys and values.
- * @param string $prefix Only keys having the specified prefix will be set.
- */
- function setProperties($properties, $prefix)
- {
- LoggerLog::debug("LoggerOptionConverter::setProperties():prefix=[{$prefix}]");
+ /**
+ * Set the properites for the object that match the
+ * <code>prefix</code> passed as parameter.
+ *
+ * @param array $properties An array containing keys and values.
+ * @param string $prefix Only keys having the specified prefix will be set.
+ */
+ function setProperties($properties, $prefix) {
+ LoggerLog::debug("LoggerOptionConverter::setProperties():prefix=[{$prefix}]");
- $len = strlen($prefix);
- while (list($key,) = each($properties)) {
- if (strpos($key, $prefix) === 0) {
- if (strpos($key, '.', ($len + 1)) > 0)
- continue;
- $value = LoggerOptionConverter::findAndSubst($key, $properties);
- $key = substr($key, $len);
- if ($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
- continue;
- }
- $this->setProperty($key, $value);
- }
- }
- $this->activate();
- }
-
- /**
- * Set a property on this PropertySetter's Object. If successful, this
- * method will invoke a setter method on the underlying Object. The
- * setter is the one for the specified property name and the value is
- * determined partly from the setter argument type and partly from the
- * value specified in the call to this method.
- *
- * <p>If the setter expects a String no conversion is necessary.
- * If it expects an int, then an attempt is made to convert 'value'
- * to an int using new Integer(value). If the setter expects a boolean,
- * the conversion is by new Boolean(value).
- *
- * @param string $name name of the property
- * @param string $value String value of the property
- */
- function setProperty($name, $value)
- {
- LoggerLog::debug("LoggerOptionConverter::setProperty():name=[{$name}]:value=[{$value}]");
+ $len = strlen($prefix);
+ while(list($key,) = each($properties)) {
+ if(strpos($key, $prefix) === 0) {
+ if(strpos($key, '.', ($len + 1)) > 0) {
+ continue;
+ }
+ $value = LoggerOptionConverter::findAndSubst($key, $properties);
+ $key = substr($key, $len);
+ if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
+ continue;
+ }
+ $this->setProperty($key, $value);
+ }
+ }
+ $this->activate();
+ }
+
+ /**
+ * Set a property on this PropertySetter's Object. If successful, this
+ * method will invoke a setter method on the underlying Object. The
+ * setter is the one for the specified property name and the value is
+ * determined partly from the setter argument type and partly from the
+ * value specified in the call to this method.
+ *
+ * <p>If the setter expects a String no conversion is necessary.
+ * If it expects an int, then an attempt is made to convert 'value'
+ * to an int using new Integer(value). If the setter expects a boolean,
+ * the conversion is by new Boolean(value).
+ *
+ * @param string $name name of the property
+ * @param string $value String value of the property
+ */
+ function setProperty($name, $value) {
+ LoggerLog::debug("LoggerOptionConverter::setProperty():name=[{$name}]:value=[{$value}]");
- if ($value === null) return;
-
- $method = "set" . ucfirst($name);
-
- if (!method_exists($this->obj, $method)) {
- LoggerLog::warn(
- "LoggerOptionConverter::setProperty() No such setter method for [{$name}] property in " .
- get_class($this->obj) . "."
- );
- } else {
- return call_user_func(array(&$this->obj, $method), $value);
- }
- }
+ if($value === null) {
+ return;
+ }
+
+ $method = "set" . ucfirst($name);
+
+ if(!method_exists($this->obj, $method)) {
+ LoggerLog::warn(
+ "LoggerOptionConverter::setProperty() No such setter method for [{$name}] property in " .
+ get_class($this->obj) . "."
+ );
+ } else {
+ return call_user_func(array(&$this->obj, $method), $value);
+ }
+ }
- function activate()
- {
- LoggerLog::debug("LoggerOptionConverter::activate()");
-
- if (method_exists($this->obj, 'activateoptions')) {
- return call_user_func(array(&$this->obj, 'activateoptions'));
- } else {
- LoggerLog::debug("LoggerOptionConverter::activate() Nothing to activate.");
- }
- }
+ function activate() {
+ LoggerLog::debug("LoggerOptionConverter::activate()");
+
+ if(method_exists($this->obj, 'activateoptions')) {
+ return call_user_func(array(&$this->obj, 'activateoptions'));
+ } else {
+ LoggerLog::debug("LoggerOptionConverter::activate() Nothing to activate.");
+ }
+ }
}
Modified: incubator/log4php/trunk/src/main/php/helpers/LoggerFormattingInfo.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerFormattingInfo.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerFormattingInfo.php (original)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerFormattingInfo.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,24 +30,22 @@
*/
class LoggerFormattingInfo {
- var $min = -1;
- var $max = 0x7FFFFFFF;
- var $leftAlign = false;
+ var $min = -1;
+ var $max = 0x7FFFFFFF;
+ var $leftAlign = false;
- /**
- * Constructor
- */
- function LoggerFormattingInfo() {}
-
- function reset()
- {
- $this->min = -1;
- $this->max = 0x7FFFFFFF;
- $this->leftAlign = false;
- }
+ /**
+ * Constructor
+ */
+ function LoggerFormattingInfo() {}
+
+ function reset() {
+ $this->min = -1;
+ $this->max = 0x7FFFFFFF;
+ $this->leftAlign = false;
+ }
- function dump()
- {
- LoggerLog::debug("LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}");
- }
-}
+ function dump() {
+ LoggerLog::debug("LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}");
+ }
+}
Modified: incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php (original)
+++ incubator/log4php/trunk/src/main/php/helpers/LoggerOptionConverter.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,10 +20,10 @@
* @subpackage helpers
*/
-define('LOG4PHP_OPTION_CONVERTER_DELIM_START', '${');
-define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP', '}');
-define('LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN', 2);
-define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN', 1);
+define('LOG4PHP_OPTION_CONVERTER_DELIM_START', '${');
+define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP', '}');
+define('LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN', 2);
+define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN', 1);
/**
* A convenience class to convert property values to specific types.
@@ -36,33 +36,32 @@
*/
class LoggerOptionConverter {
- /**
- * @param array $l
- * @param array $r
- * @return array
- *
- * @static
- */
- public static function concatanateArrays($l, $r)
- {
- return array_merge($l, $r);
- }
-
- /**
- * Read a predefined var.
- *
- * It returns a value referenced by <var>$key</var> using this search criteria:
- * - if <var>$key</var> is a constant then return it. Else
- * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
- * - return <var>$def</var>.
- *
- * @param string $key The key to search for.
- * @param string $def The default value to return.
- * @return string the string value of the system property, or the default
- * value if there is no property with that key.
- *
- * @static
- */
+ /**
+ * @param array $l
+ * @param array $r
+ * @return array
+ *
+ * @static
+ */
+ public static function concatanateArrays($l, $r) {
+ return array_merge($l, $r);
+ }
+
+ /**
+ * Read a predefined var.
+ *
+ * It returns a value referenced by <var>$key</var> using this search criteria:
+ * - if <var>$key</var> is a constant then return it. Else
+ * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
+ * - return <var>$def</var>.
+ *
+ * @param string $key The key to search for.
+ * @param string $def The default value to return.
+ * @return string the string value of the system property, or the default
+ * value if there is no property with that key.
+ *
+ * @static
+ */
public static function getSystemProperty($key, $def) {
LoggerLog::debug("LoggerOptionConverter::getSystemProperty():key=[{$key}]:def=[{$def}].");
@@ -77,258 +76,257 @@
}
}
- /**
- * If <var>$value</var> is <i>true</i>, then <i>true</i> is
- * returned. If <var>$value</var> is <i>false</i>, then
- * <i>true</i> is returned. Otherwise, <var>$default</var> is
- * returned.
- *
- * <p>Case of value is unimportant.</p>
- *
- * @param string $value
- * @param boolean $default
- * @return boolean
- *
- * @static
- */
- public static function toBoolean($value, $default)
- {
- if($value === null)
- return $default;
- if ($value == 1)
- return true;
- $trimmedVal = strtolower(trim($value));
- if ("true" == $trimmedVal or "yes" == $trimmedVal)
- return true;
- if ("false" == $trimmedVal)
- return false;
- return $default;
- }
-
- /**
- * @param string $value
- * @param integer $default
- * @return integer
- * @static
- */
- public static function toInt($value, $default)
- {
- $value = trim($value);
- if (is_numeric($value)) {
- return (int)$value;
- } else {
- return $default;
- }
- }
-
- /**
- * Converts a standard or custom priority level to a Level
- * object.
- *
- * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
- * where <i>full_file_classname</i> means the class filename with path
- * but without php extension, then the specified class' <i>toLevel()</i> method
- * is called to process the specified level string; if no '#'
- * character is present, then the default {@link LoggerLevel}
- * class is used to process the level value.</p>
- *
- * <p>As a special case, if the <var>$value</var> parameter is
- * equal to the string "NULL", then the value <i>null</i> will
- * be returned.</p>
- *
- * <p>If any error occurs while converting the value to a level,
- * the <var>$defaultValue</var> parameter, which may be
- * <i>null</i>, is returned.</p>
- *
- * <p>Case of <var>$value</var> is insignificant for the level level, but is
- * significant for the class name part, if present.</p>
- *
- * @param string $value
- * @param LoggerLevel $defaultValue
- * @return LoggerLevel a {@link LoggerLevel} or null
- * @static
- */
- public static function toLevel($value, $defaultValue)
- {
- if($value === null)
- return $defaultValue;
-
- $hashIndex = strpos($value, '#');
- if ($hashIndex === false) {
- if("NULL" == strtoupper($value)) {
- return null;
- } else {
- // no class name specified : use standard Level class
- return LoggerLevel::toLevel($value, $defaultValue);
- }
- }
-
- $result = $defaultValue;
-
- $clazz = substr($value, ($hashIndex + 1));
- $levelName = substr($value, 0, $hashIndex);
-
- // This is degenerate case but you never know.
- if("NULL" == strtoupper($levelName)) {
- return null;
- }
-
- LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}]:pri=[{$levelName}]");
-
- $clazz = basename($clazz);
-
- if (class_exists($clazz)) {
- $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
- if (!is_a($result, 'loggerlevel')) {
- LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}] cannot call toLevel(). Returning default.");
- $result = $defaultValue;
- }
- } else {
- LoggerLog::warn("LoggerOptionConverter::toLevel() class '{$clazz}' doesnt exists.");
- }
- return $result;
- }
-
- /**
- * @param string $value
- * @param float $default
- * @return float
- *
- * @static
- */
- public static function toFileSize($value, $default)
- {
- if ($value === null)
- return $default;
-
- $s = strtoupper(trim($value));
- $multiplier = (float)1;
- if(($index = strpos($s, 'KB')) !== false) {
- $multiplier = 1024;
- $s = substr($s, 0, $index);
- } elseif(($index = strpos($s, 'MB')) !== false) {
- $multiplier = 1024 * 1024;
- $s = substr($s, 0, $index);
- } elseif(($index = strpos($s, 'GB')) !== false) {
- $multiplier = 1024 * 1024 * 1024;
- $s = substr($s, 0, $index);
- }
- if(is_numeric($s)) {
- return (float)$s * $multiplier;
- } else {
- LoggerLog::warn("LoggerOptionConverter::toFileSize() [{$s}] is not in proper form.");
- }
- return $default;
- }
-
- /**
- * Find the value corresponding to <var>$key</var> in
- * <var>$props</var>. Then perform variable substitution on the
- * found value.
- *
- * @param string $key
- * @param array $props
- * @return string
- *
- * @static
- */
- public static function findAndSubst($key, $props)
- {
- $value = @$props[$key];
- if(empty($value)) {
- return null;
- }
- return LoggerOptionConverter::substVars($value, $props);
- }
-
- /**
- * Perform variable substitution in string <var>$val</var> from the
- * values of keys found with the {@link getSystemProperty()} method.
- *
- * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
- *
- * <p>For example, if the "MY_CONSTANT" contains "value", then
- * the call
- * <code>
- * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
- * </code>
- * will set the variable <i>$s</i> to "Value of key is value.".</p>
- *
- * <p>If no value could be found for the specified key, then the
- * <var>$props</var> parameter is searched, if the value could not
- * be found there, then substitution defaults to the empty string.</p>
- *
- * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
- * "inexistentKey", then the call
- * <code>
- * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
- * </code>
- * will set <var>$s</var> to "Value of inexistentKey is []".</p>
- *
- * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${"
- * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
- *
- * @log4j-author Avy Sharell
- *
- * @param string $val The string on which variable substitution is performed.
- * @param array $props
- * @return string
- *
- * @static
- */
- public static function substVars($val, $props = null)
- {
- LoggerLog::debug("LoggerOptionConverter::substVars():val=[{$val}]");
-
- $sbuf = '';
- $i = 0;
- while(true) {
- $j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i);
- if ($j === false) {
- LoggerLog::debug("LoggerOptionConverter::substVars() no more variables");
- // no more variables
- if ($i == 0) { // this is a simple string
- LoggerLog::debug("LoggerOptionConverter::substVars() simple string");
- return $val;
- } else { // add the tail string which contails no variables and return the result.
- $sbuf .= substr($val, $i);
- LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]. Returning sbuf");
- return $sbuf;
- }
- } else {
-
- $sbuf .= substr($val, $i, $j-$i);
- LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}.");
- $k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j);
- if ($k === false) {
- LoggerLog::warn(
- "LoggerOptionConverter::substVars() " .
- "'{$val}' has no closing brace. Opening brace at position {$j}."
- );
- return '';
- } else {
- $j += LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN;
- $key = substr($val, $j, $k - $j);
- // first try in System properties
- $replacement = LoggerOptionConverter::getSystemProperty($key, null);
- // then try props parameter
- if($replacement == null and $props !== null) {
- $replacement = @$props[$key];
- }
-
- if(!empty($replacement)) {
- // Do variable substitution on the replacement string
- // such that we can solve "Hello ${x2}" as "Hello p1"
- // the where the properties are
- // x1=p1
- // x2=${x1}
- $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
- $sbuf .= $recursiveReplacement;
- }
- $i = $k + LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN;
- }
- }
- }
- }
+ /**
+ * If <var>$value</var> is <i>true</i>, then <i>true</i> is
+ * returned. If <var>$value</var> is <i>false</i>, then
+ * <i>true</i> is returned. Otherwise, <var>$default</var> is
+ * returned.
+ *
+ * <p>Case of value is unimportant.</p>
+ *
+ * @param string $value
+ * @param boolean $default
+ * @return boolean
+ *
+ * @static
+ */
+ public static function toBoolean($value, $default) {
+ if($value === null) {
+ return $default;
+ }
+ if($value == 1) {
+ return true;
+ }
+ $trimmedVal = strtolower(trim($value));
+ if("true" == $trimmedVal or "yes" == $trimmedVal) {
+ return true;
+ }
+ if("false" == $trimmedVal) {
+ return false;
+ }
+ return $default;
+ }
+
+ /**
+ * @param string $value
+ * @param integer $default
+ * @return integer
+ * @static
+ */
+ public static function toInt($value, $default) {
+ $value = trim($value);
+ if(is_numeric($value)) {
+ return (int)$value;
+ } else {
+ return $default;
+ }
+ }
+
+ /**
+ * Converts a standard or custom priority level to a Level
+ * object.
+ *
+ * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
+ * where <i>full_file_classname</i> means the class filename with path
+ * but without php extension, then the specified class' <i>toLevel()</i> method
+ * is called to process the specified level string; if no '#'
+ * character is present, then the default {@link LoggerLevel}
+ * class is used to process the level value.</p>
+ *
+ * <p>As a special case, if the <var>$value</var> parameter is
+ * equal to the string "NULL", then the value <i>null</i> will
+ * be returned.</p>
+ *
+ * <p>If any error occurs while converting the value to a level,
+ * the <var>$defaultValue</var> parameter, which may be
+ * <i>null</i>, is returned.</p>
+ *
+ * <p>Case of <var>$value</var> is insignificant for the level level, but is
+ * significant for the class name part, if present.</p>
+ *
+ * @param string $value
+ * @param LoggerLevel $defaultValue
+ * @return LoggerLevel a {@link LoggerLevel} or null
+ * @static
+ */
+ public static function toLevel($value, $defaultValue) {
+ if($value === null) {
+ return $defaultValue;
+ }
+ $hashIndex = strpos($value, '#');
+ if($hashIndex === false) {
+ if("NULL" == strtoupper($value)) {
+ return null;
+ } else {
+ // no class name specified : use standard Level class
+ return LoggerLevel::toLevel($value, $defaultValue);
+ }
+ }
+
+ $result = $defaultValue;
+
+ $clazz = substr($value, ($hashIndex + 1));
+ $levelName = substr($value, 0, $hashIndex);
+
+ // This is degenerate case but you never know.
+ if("NULL" == strtoupper($levelName)) {
+ return null;
+ }
+
+ LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}]:pri=[{$levelName}]");
+
+ $clazz = basename($clazz);
+
+ if(class_exists($clazz)) {
+ $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
+ if(!is_a($result, 'loggerlevel')) {
+ LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}] cannot call toLevel(). Returning default.");
+ $result = $defaultValue;
+ }
+ } else {
+ LoggerLog::warn("LoggerOptionConverter::toLevel() class '{$clazz}' doesnt exists.");
+ }
+ return $result;
+ }
+
+ /**
+ * @param string $value
+ * @param float $default
+ * @return float
+ *
+ * @static
+ */
+ public static function toFileSize($value, $default) {
+ if($value === null) {
+ return $default;
+ }
+
+ $s = strtoupper(trim($value));
+ $multiplier = (float)1;
+ if(($index = strpos($s, 'KB')) !== false) {
+ $multiplier = 1024;
+ $s = substr($s, 0, $index);
+ } else if(($index = strpos($s, 'MB')) !== false) {
+ $multiplier = 1024 * 1024;
+ $s = substr($s, 0, $index);
+ } else if(($index = strpos($s, 'GB')) !== false) {
+ $multiplier = 1024 * 1024 * 1024;
+ $s = substr($s, 0, $index);
+ }
+ if(is_numeric($s)) {
+ return (float)$s * $multiplier;
+ } else {
+ LoggerLog::warn("LoggerOptionConverter::toFileSize() [{$s}] is not in proper form.");
+ }
+ return $default;
+ }
+
+ /**
+ * Find the value corresponding to <var>$key</var> in
+ * <var>$props</var>. Then perform variable substitution on the
+ * found value.
+ *
+ * @param string $key
+ * @param array $props
+ * @return string
+ *
+ * @static
+ */
+ public static function findAndSubst($key, $props) {
+ $value = @$props[$key];
+ if(empty($value)) {
+ return null;
+ }
+ return LoggerOptionConverter::substVars($value, $props);
+ }
+
+ /**
+ * Perform variable substitution in string <var>$val</var> from the
+ * values of keys found with the {@link getSystemProperty()} method.
+ *
+ * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
+ *
+ * <p>For example, if the "MY_CONSTANT" contains "value", then
+ * the call
+ * <code>
+ * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
+ * </code>
+ * will set the variable <i>$s</i> to "Value of key is value.".</p>
+ *
+ * <p>If no value could be found for the specified key, then the
+ * <var>$props</var> parameter is searched, if the value could not
+ * be found there, then substitution defaults to the empty string.</p>
+ *
+ * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
+ * "inexistentKey", then the call
+ * <code>
+ * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
+ * </code>
+ * will set <var>$s</var> to "Value of inexistentKey is []".</p>
+ *
+ * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${"
+ * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
+ *
+ * @log4j-author Avy Sharell
+ *
+ * @param string $val The string on which variable substitution is performed.
+ * @param array $props
+ * @return string
+ *
+ * @static
+ */
+ public static function substVars($val, $props = null) {
+ LoggerLog::debug("LoggerOptionConverter::substVars():val=[{$val}]");
+
+ $sbuf = '';
+ $i = 0;
+ while(true) {
+ $j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i);
+ if($j === false) {
+ LoggerLog::debug("LoggerOptionConverter::substVars() no more variables");
+ // no more variables
+ if($i == 0) { // this is a simple string
+ LoggerLog::debug("LoggerOptionConverter::substVars() simple string");
+ return $val;
+ } else { // add the tail string which contails no variables and return the result.
+ $sbuf .= substr($val, $i);
+ LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]. Returning sbuf");
+ return $sbuf;
+ }
+ } else {
+
+ $sbuf .= substr($val, $i, $j-$i);
+ LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}.");
+ $k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j);
+ if($k === false) {
+ LoggerLog::warn(
+ "LoggerOptionConverter::substVars() " .
+ "'{$val}' has no closing brace. Opening brace at position {$j}."
+ );
+ return '';
+ } else {
+ $j += LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN;
+ $key = substr($val, $j, $k - $j);
+ // first try in System properties
+ $replacement = LoggerOptionConverter::getSystemProperty($key, null);
+ // then try props parameter
+ if($replacement == null and $props !== null) {
+ $replacement = @$props[$key];
+ }
+
+ if(!empty($replacement)) {
+ // Do variable substitution on the replacement string
+ // such that we can solve "Hello ${x2}" as "Hello p1"
+ // the where the properties are
+ // x1=p1
+ // x2=${x1}
+ $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
+ $sbuf .= $recursiveReplacement;
+ }
+ $i = $k + LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN;
+ }
+ }
+ }
+ }
}
Modified: incubator/log4php/trunk/src/main/php/or/LoggerDefaultRenderer.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/or/LoggerDefaultRenderer.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/or/LoggerDefaultRenderer.php (original)
+++ incubator/log4php/trunk/src/main/php/or/LoggerDefaultRenderer.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,15 +27,15 @@
* @subpackage or
* @since 0.3
*/
-class LoggerDefaultRenderer extends LoggerObjectRenderer{
-
- /**
- * Render objects by type casting
- *
- * @param mixed $o the object to render
- * @return string
- */
- public function doRender($o) {
- return var_export($o, true);
- }
+class LoggerDefaultRenderer extends LoggerObjectRenderer {
+
+ /**
+ * Render objects by type casting
+ *
+ * @param mixed $o the object to render
+ * @return string
+ */
+ public function doRender($o) {
+ return var_export($o, true);
+ }
}
Modified: incubator/log4php/trunk/src/main/php/or/LoggerObjectRenderer.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/or/LoggerObjectRenderer.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/or/LoggerObjectRenderer.php (original)
+++ incubator/log4php/trunk/src/main/php/or/LoggerObjectRenderer.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -31,22 +31,22 @@
*/
abstract class LoggerObjectRenderer {
- /**
- * @param string $class classname
- * @return LoggerObjectRenderer create LoggerObjectRenderer instances
- */
- public static function factory($class) {
- if (!empty($class)) {
- $class = basename($class);
- return new $class();
- }
- return null;
- }
+ /**
+ * @param string $class classname
+ * @return LoggerObjectRenderer create LoggerObjectRenderer instances
+ */
+ public static function factory($class) {
+ if(!empty($class)) {
+ $class = basename($class);
+ return new $class();
+ }
+ return null;
+ }
- /**
- * Render the entity passed as parameter as a String.
- * @param mixed $o entity to render
- * @return string
- */
- abstract public function doRender($o);
+ /**
+ * Render the entity passed as parameter as a String.
+ * @param mixed $o entity to render
+ * @return string
+ */
+ abstract public function doRender($o);
}
Modified: incubator/log4php/trunk/src/main/php/or/LoggerRendererMap.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/or/LoggerRendererMap.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/or/LoggerRendererMap.php (original)
+++ incubator/log4php/trunk/src/main/php/or/LoggerRendererMap.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,142 +30,133 @@
*/
class LoggerRendererMap {
- /**
- * @var array
- */
- var $map;
-
- /**
- * @var LoggerDefaultRenderer
- */
- var $defaultRenderer;
-
- /**
- * Constructor
- */
- public function __construct()
- {
- $this->map = array();
- $this->defaultRenderer = new LoggerDefaultRenderer();
- }
-
- /**
- * Add a renderer to a hierarchy passed as parameter.
- * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
- *
- * @param LoggerHierarchy $repository a logger repository.
- * @param string $renderedClassName
- * @param string $renderingClassName
- * @static
- */
- public static function addRenderer($repository, $renderedClassName, $renderingClassName)
- {
- LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}].");
- $renderer = LoggerObjectRenderer::factory($renderingClassName);
- if($renderer == null) {
- LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}].");
- return;
- } else {
- $repository->setRenderer($renderedClassName, $renderer);
- }
- }
-
-
- /**
- * Find the appropriate renderer for the class type of the
- * <var>o</var> parameter.
- *
- * This is accomplished by calling the {@link getByObject()}
- * method if <var>o</var> is object or using {@link LoggerDefaultRenderer}.
- * Once a renderer is found, it is applied on the object <var>o</var> and
- * the result is returned as a string.
- *
- * @param mixed $o
- * @return string
- */
- public function findAndRender($o)
- {
- if($o == null) {
- return null;
- } else {
- if (is_object($o)) {
- $renderer = $this->getByObject($o);
- if ($renderer !== null) {
- return $renderer->doRender($o);
- } else {
- return null;
- }
- } else {
- $renderer = $this->defaultRenderer;
- return $renderer->doRender($o);
- }
- }
- }
-
- /**
- * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
- * class of the object parameter.
- *
- * @param mixed $o
- * @return string
- */
- public function getByObject($o)
- {
- return ($o == null) ? null : $this->getByClassName(get_class($o));
- }
-
-
- /**
- * Search the parents of <var>clazz</var> for a renderer.
- *
- * The renderer closest in the hierarchy will be returned. If no
- * renderers could be found, then the default renderer is returned.
- *
- * @param string $class
- * @return LoggerObjectRenderer
- */
- public function getByClassName($class)
- {
- $r = null;
- for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
- if (isset($this->map[$c])) {
- return $this->map[$c];
- }
- }
- return $this->defaultRenderer;
- }
-
- /**
- * @return LoggerDefaultRenderer
- */
- public function getDefaultRenderer()
- {
- return $this->defaultRenderer;
- }
-
-
- public function clear()
- {
- $this->map = array();
- }
-
- /**
- * Register a {@link LoggerObjectRenderer} for <var>clazz</var>.
- * @param string $class
- * @param LoggerObjectRenderer $or
- */
- public function put($class, $or)
- {
- $this->map[strtolower($class)] = $or;
- }
-
- /**
- * @param string $class
- * @return boolean
- */
- public function rendererExists($class)
- {
- $class = basename($class);
- return class_exists($class);
- }
+ /**
+ * @var array
+ */
+ var $map;
+
+ /**
+ * @var LoggerDefaultRenderer
+ */
+ var $defaultRenderer;
+
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ $this->map = array();
+ $this->defaultRenderer = new LoggerDefaultRenderer();
+ }
+
+ /**
+ * Add a renderer to a hierarchy passed as parameter.
+ * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
+ *
+ * @param LoggerHierarchy $repository a logger repository.
+ * @param string $renderedClassName
+ * @param string $renderingClassName
+ * @static
+ */
+ public static function addRenderer($repository, $renderedClassName, $renderingClassName) {
+ LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}].");
+ $renderer = LoggerObjectRenderer::factory($renderingClassName);
+ if($renderer == null) {
+ LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}].");
+ return;
+ } else {
+ $repository->setRenderer($renderedClassName, $renderer);
+ }
+ }
+
+
+ /**
+ * Find the appropriate renderer for the class type of the
+ * <var>o</var> parameter.
+ *
+ * This is accomplished by calling the {@link getByObject()}
+ * method if <var>o</var> is object or using {@link LoggerDefaultRenderer}.
+ * Once a renderer is found, it is applied on the object <var>o</var> and
+ * the result is returned as a string.
+ *
+ * @param mixed $o
+ * @return string
+ */
+ public function findAndRender($o) {
+ if($o == null) {
+ return null;
+ } else {
+ if(is_object($o)) {
+ $renderer = $this->getByObject($o);
+ if($renderer !== null) {
+ return $renderer->doRender($o);
+ } else {
+ return null;
+ }
+ } else {
+ $renderer = $this->defaultRenderer;
+ return $renderer->doRender($o);
+ }
+ }
+ }
+
+ /**
+ * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
+ * class of the object parameter.
+ *
+ * @param mixed $o
+ * @return string
+ */
+ public function getByObject($o) {
+ return ($o == null) ? null : $this->getByClassName(get_class($o));
+ }
+
+
+ /**
+ * Search the parents of <var>clazz</var> for a renderer.
+ *
+ * The renderer closest in the hierarchy will be returned. If no
+ * renderers could be found, then the default renderer is returned.
+ *
+ * @param string $class
+ * @return LoggerObjectRenderer
+ */
+ public function getByClassName($class) {
+ $r = null;
+ for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
+ if(isset($this->map[$c])) {
+ return $this->map[$c];
+ }
+ }
+ return $this->defaultRenderer;
+ }
+
+ /**
+ * @return LoggerDefaultRenderer
+ */
+ public function getDefaultRenderer() {
+ return $this->defaultRenderer;
+ }
+
+
+ public function clear() {
+ $this->map = array();
+ }
+
+ /**
+ * Register a {@link LoggerObjectRenderer} for <var>clazz</var>.
+ * @param string $class
+ * @param LoggerObjectRenderer $or
+ */
+ public function put($class, $or) {
+ $this->map[strtolower($class)] = $or;
+ }
+
+ /**
+ * @param string $class
+ * @return boolean
+ */
+ public function rendererExists($class) {
+ $class = basename($class);
+ return class_exists($class);
+ }
}
Modified: incubator/log4php/trunk/src/main/php/spi/LoggerConfigurator.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/spi/LoggerConfigurator.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/spi/LoggerConfigurator.php (original)
+++ incubator/log4php/trunk/src/main/php/spi/LoggerConfigurator.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -32,25 +32,25 @@
* {@link LOG4PHP_LOGGER_CONFIGURATOR_INHERITED}.
* The current value of this string constant is <b>null</b>.
*/
-define('LOG4PHP_LOGGER_CONFIGURATOR_NULL', 'null');
+define('LOG4PHP_LOGGER_CONFIGURATOR_NULL', 'null');
/**
* Implemented by classes capable of configuring log4php using a URL.
- *
+ *
* @version $Revision$
* @package log4php
- * @subpackage spi
+ * @subpackage spi
*/
interface LoggerConfigurator {
- /**
- * Interpret a resource pointed by a <var>url</var> and configure accordingly.
- *
- * The configuration is done relative to the <var>repository</var>
- * parameter.
- *
- * @param string $url The URL to parse
- */
- public static function configure($url=null);
-
+ /**
+ * Interpret a resource pointed by a <var>url</var> and configure accordingly.
+ *
+ * The configuration is done relative to the <var>repository</var>
+ * parameter.
+ *
+ * @param string $url The URL to parse
+ */
+ public static function configure($url = null);
+
}
Modified: incubator/log4php/trunk/src/main/php/spi/LoggerFactory.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/spi/LoggerFactory.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/spi/LoggerFactory.php (original)
+++ incubator/log4php/trunk/src/main/php/spi/LoggerFactory.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -32,11 +32,11 @@
*/
abstract class LoggerFactory {
- /**
- * @abstract
- * @param string $name
- * @return Logger
- */
- abstract function makeNewLoggerInstance($name);
+ /**
+ * @abstract
+ * @param string $name
+ * @return Logger
+ */
+ abstract function makeNewLoggerInstance($name);
}
Modified: incubator/log4php/trunk/src/main/php/spi/LoggerFilter.php
URL: http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/spi/LoggerFilter.php?rev=771037&r1=771036&r2=771037&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/spi/LoggerFilter.php (original)
+++ incubator/log4php/trunk/src/main/php/spi/LoggerFilter.php Sun May 3 07:52:46 2009
@@ -1,13 +1,13 @@
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -60,7 +60,7 @@
/**
* The log event must be logged immediately without consulting with
- * the remaining filters, if any, in the chain.
+ * the remaining filters, if any, in the chain.
*/
const ACCEPT = 1;
@@ -76,38 +76,36 @@
*/
const DENY = -1;
- /**
- * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain.
- */
- protected $next;
-
- /**
- * Usually filters options become active when set. We provide a
- * default do-nothing implementation for convenience.
- */
- public function activateOptions()
- {
- return;
- }
-
- /**
- * Decide what to do.
- * <p>If the decision is {@link LoggerFilter::DENY}, then the event will be
- * dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next
- * filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then
- * the event will be logged without consulting with other filters in
- * the chain.
- *
- * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon.
- * @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT}
- */
- public function decide($event)
- {
- return self::NEUTRAL;
- }
-
- public function getNext() {
- return $this->next;
- }
+ /**
+ * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain.
+ */
+ protected $next;
+
+ /**
+ * Usually filters options become active when set. We provide a
+ * default do-nothing implementation for convenience.
+ */
+ public function activateOptions() {
+ return;
+ }
+
+ /**
+ * Decide what to do.
+ * <p>If the decision is {@link LoggerFilter::DENY}, then the event will be
+ * dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next
+ * filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then
+ * the event will be logged without consulting with other filters in
+ * the chain.
+ *
+ * @param LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon.
+ * @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT}
+ */
+ public function decide($event) {
+ return self::NEUTRAL;
+ }
+
+ public function getNext() {
+ return $this->next;
+ }
}