@@ -53,109 +53,109 @@ |
||
| 53 | 53 | */ |
| 54 | 54 | class LoggerPropertySetter { |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var object the target object |
|
| 58 | - * @access private |
|
| 59 | - */ |
|
| 60 | - var $obj; |
|
| 56 | + /** |
|
| 57 | + * @var object the target object |
|
| 58 | + * @access private |
|
| 59 | + */ |
|
| 60 | + var $obj; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Create a new LoggerPropertySetter for the specified Object. |
|
| 64 | - * This is done in prepartion for invoking {@link setProperty()} |
|
| 65 | - * one or more times. |
|
| 66 | - * @param object &$obj the object for which to set properties |
|
| 67 | - */ |
|
| 68 | - public function LoggerPropertySetter(&$obj) |
|
| 69 | - { |
|
| 70 | - $this->obj =& $obj; |
|
| 71 | - } |
|
| 62 | + /** |
|
| 63 | + * Create a new LoggerPropertySetter for the specified Object. |
|
| 64 | + * This is done in prepartion for invoking {@link setProperty()} |
|
| 65 | + * one or more times. |
|
| 66 | + * @param object &$obj the object for which to set properties |
|
| 67 | + */ |
|
| 68 | + public function LoggerPropertySetter(&$obj) |
|
| 69 | + { |
|
| 70 | + $this->obj =& $obj; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Set the properties of an object passed as a parameter in one |
|
| 75 | - * go. The <code>properties</code> are parsed relative to a |
|
| 76 | - * <code>prefix</code>. |
|
| 77 | - * |
|
| 78 | - * @param object &$obj The object to configure. |
|
| 79 | - * @param array $properties An array containing keys and values. |
|
| 80 | - * @param string $prefix Only keys having the specified prefix will be set. |
|
| 81 | - * @static |
|
| 82 | - */ |
|
| 83 | - public function setPropertiesByObject(&$obj, $properties, $prefix) |
|
| 84 | - { |
|
| 85 | - $pSetter = new LoggerPropertySetter($obj); |
|
| 86 | - return $pSetter->setProperties($properties, $prefix); |
|
| 87 | - } |
|
| 73 | + /** |
|
| 74 | + * Set the properties of an object passed as a parameter in one |
|
| 75 | + * go. The <code>properties</code> are parsed relative to a |
|
| 76 | + * <code>prefix</code>. |
|
| 77 | + * |
|
| 78 | + * @param object &$obj The object to configure. |
|
| 79 | + * @param array $properties An array containing keys and values. |
|
| 80 | + * @param string $prefix Only keys having the specified prefix will be set. |
|
| 81 | + * @static |
|
| 82 | + */ |
|
| 83 | + public function setPropertiesByObject(&$obj, $properties, $prefix) |
|
| 84 | + { |
|
| 85 | + $pSetter = new LoggerPropertySetter($obj); |
|
| 86 | + return $pSetter->setProperties($properties, $prefix); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Set the properites for the object that match the |
|
| 92 | - * <code>prefix</code> passed as parameter. |
|
| 93 | - * |
|
| 94 | - * @param array $properties An array containing keys and values. |
|
| 95 | - * @param string $prefix Only keys having the specified prefix will be set. |
|
| 96 | - */ |
|
| 97 | - public function setProperties($properties, $prefix) |
|
| 98 | - { |
|
| 99 | - LoggerLog::debug("LoggerOptionConverter::setProperties():prefix=[{$prefix}]"); |
|
| 90 | + /** |
|
| 91 | + * Set the properites for the object that match the |
|
| 92 | + * <code>prefix</code> passed as parameter. |
|
| 93 | + * |
|
| 94 | + * @param array $properties An array containing keys and values. |
|
| 95 | + * @param string $prefix Only keys having the specified prefix will be set. |
|
| 96 | + */ |
|
| 97 | + public function setProperties($properties, $prefix) |
|
| 98 | + { |
|
| 99 | + LoggerLog::debug("LoggerOptionConverter::setProperties():prefix=[{$prefix}]"); |
|
| 100 | 100 | |
| 101 | - $len = strlen($prefix); |
|
| 102 | - while (list($key,) = each($properties)) { |
|
| 103 | - if (strpos($key, $prefix) === 0) { |
|
| 104 | - if (strpos($key, '.', ($len + 1)) > 0) |
|
| 105 | - continue; |
|
| 106 | - $value = LoggerOptionConverter::findAndSubst($key, $properties); |
|
| 107 | - $key = substr($key, $len); |
|
| 108 | - if ($key == 'layout' && is_a($this->obj, 'loggerappender')) { |
|
| 109 | - continue; |
|
| 110 | - } |
|
| 111 | - $this->setProperty($key, $value); |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - $this->activate(); |
|
| 115 | - } |
|
| 101 | + $len = strlen($prefix); |
|
| 102 | + while (list($key,) = each($properties)) { |
|
| 103 | + if (strpos($key, $prefix) === 0) { |
|
| 104 | + if (strpos($key, '.', ($len + 1)) > 0) |
|
| 105 | + continue; |
|
| 106 | + $value = LoggerOptionConverter::findAndSubst($key, $properties); |
|
| 107 | + $key = substr($key, $len); |
|
| 108 | + if ($key == 'layout' && is_a($this->obj, 'loggerappender')) { |
|
| 109 | + continue; |
|
| 110 | + } |
|
| 111 | + $this->setProperty($key, $value); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + $this->activate(); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Set a property on this PropertySetter's Object. If successful, this |
|
| 119 | - * method will invoke a setter method on the underlying Object. The |
|
| 120 | - * setter is the one for the specified property name and the value is |
|
| 121 | - * determined partly from the setter argument type and partly from the |
|
| 122 | - * value specified in the call to this method. |
|
| 123 | - * |
|
| 124 | - * <p>If the setter expects a String no conversion is necessary. |
|
| 125 | - * If it expects an int, then an attempt is made to convert 'value' |
|
| 126 | - * to an int using new Integer(value). If the setter expects a boolean, |
|
| 127 | - * the conversion is by new Boolean(value). |
|
| 128 | - * |
|
| 129 | - * @param string $name name of the property |
|
| 130 | - * @param string $value String value of the property |
|
| 131 | - */ |
|
| 132 | - public function setProperty($name, $value) |
|
| 133 | - { |
|
| 134 | - LoggerLog::debug("LoggerOptionConverter::setProperty():name=[{$name}]:value=[{$value}]"); |
|
| 117 | + /** |
|
| 118 | + * Set a property on this PropertySetter's Object. If successful, this |
|
| 119 | + * method will invoke a setter method on the underlying Object. The |
|
| 120 | + * setter is the one for the specified property name and the value is |
|
| 121 | + * determined partly from the setter argument type and partly from the |
|
| 122 | + * value specified in the call to this method. |
|
| 123 | + * |
|
| 124 | + * <p>If the setter expects a String no conversion is necessary. |
|
| 125 | + * If it expects an int, then an attempt is made to convert 'value' |
|
| 126 | + * to an int using new Integer(value). If the setter expects a boolean, |
|
| 127 | + * the conversion is by new Boolean(value). |
|
| 128 | + * |
|
| 129 | + * @param string $name name of the property |
|
| 130 | + * @param string $value String value of the property |
|
| 131 | + */ |
|
| 132 | + public function setProperty($name, $value) |
|
| 133 | + { |
|
| 134 | + LoggerLog::debug("LoggerOptionConverter::setProperty():name=[{$name}]:value=[{$value}]"); |
|
| 135 | 135 | |
| 136 | - if ($value === null) return; |
|
| 136 | + if ($value === null) return; |
|
| 137 | 137 | |
| 138 | - $method = "set" . ucfirst($name); |
|
| 138 | + $method = "set" . ucfirst($name); |
|
| 139 | 139 | |
| 140 | - if (!method_exists($this->obj, $method)) { |
|
| 141 | - LoggerLog::warn( |
|
| 142 | - "LoggerOptionConverter::setProperty() No such setter method for [{$name}] property in " . |
|
| 143 | - get_class($this->obj) . "." |
|
| 144 | - ); |
|
| 145 | - } else { |
|
| 146 | - return call_user_func(array(&$this->obj, $method), $value); |
|
| 147 | - } |
|
| 148 | - } |
|
| 140 | + if (!method_exists($this->obj, $method)) { |
|
| 141 | + LoggerLog::warn( |
|
| 142 | + "LoggerOptionConverter::setProperty() No such setter method for [{$name}] property in " . |
|
| 143 | + get_class($this->obj) . "." |
|
| 144 | + ); |
|
| 145 | + } else { |
|
| 146 | + return call_user_func(array(&$this->obj, $method), $value); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - public function activate() |
|
| 151 | - { |
|
| 152 | - LoggerLog::debug("LoggerOptionConverter::activate()"); |
|
| 150 | + public function activate() |
|
| 151 | + { |
|
| 152 | + LoggerLog::debug("LoggerOptionConverter::activate()"); |
|
| 153 | 153 | |
| 154 | - if (method_exists($this->obj, 'activateoptions')) { |
|
| 155 | - return call_user_func(array(&$this->obj, 'activateoptions')); |
|
| 156 | - } else { |
|
| 157 | - LoggerLog::debug("LoggerOptionConverter::activate() Nothing to activate."); |
|
| 158 | - } |
|
| 159 | - } |
|
| 154 | + if (method_exists($this->obj, 'activateoptions')) { |
|
| 155 | + return call_user_func(array(&$this->obj, 'activateoptions')); |
|
| 156 | + } else { |
|
| 157 | + LoggerLog::debug("LoggerOptionConverter::activate() Nothing to activate."); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | 160 | } |
| 161 | 161 | ?> |
| 162 | 162 | \ No newline at end of file |
@@ -39,42 +39,42 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class LoggerBasicConfigurator extends LoggerConfigurator { |
| 41 | 41 | |
| 42 | - public function LoggerBasicConfigurator() |
|
| 43 | - { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 42 | + public function LoggerBasicConfigurator() |
|
| 43 | + { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Add a {@link LoggerAppenderConsole} that uses |
|
| 49 | - * the {@link LoggerLayoutTTCC} to the root category. |
|
| 50 | - * |
|
| 51 | - * @param string $url not used here |
|
| 52 | - * @static |
|
| 53 | - */ |
|
| 54 | - public function configure($url = null) |
|
| 55 | - { |
|
| 56 | - $root =& LoggerManager::getRootLogger(); |
|
| 47 | + /** |
|
| 48 | + * Add a {@link LoggerAppenderConsole} that uses |
|
| 49 | + * the {@link LoggerLayoutTTCC} to the root category. |
|
| 50 | + * |
|
| 51 | + * @param string $url not used here |
|
| 52 | + * @static |
|
| 53 | + */ |
|
| 54 | + public function configure($url = null) |
|
| 55 | + { |
|
| 56 | + $root =& LoggerManager::getRootLogger(); |
|
| 57 | 57 | |
| 58 | - $appender =& LoggerAppender::singleton('A1', 'LoggerAppenderConsole'); |
|
| 59 | - $layout = LoggerLayout::factory('LoggerLayoutTTCC'); |
|
| 60 | - $appender->setLayout($layout); |
|
| 58 | + $appender =& LoggerAppender::singleton('A1', 'LoggerAppenderConsole'); |
|
| 59 | + $layout = LoggerLayout::factory('LoggerLayoutTTCC'); |
|
| 60 | + $appender->setLayout($layout); |
|
| 61 | 61 | |
| 62 | - $root->addAppender($appender); |
|
| 63 | - } |
|
| 62 | + $root->addAppender($appender); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Reset the default hierarchy to its defaut. |
|
| 67 | - * It is equivalent to |
|
| 68 | - * <code> |
|
| 69 | - * LoggerManager::resetConfiguration(); |
|
| 70 | - * </code> |
|
| 71 | - * |
|
| 72 | - * @see LoggerHierarchy::resetConfiguration() |
|
| 73 | - * @static |
|
| 74 | - */ |
|
| 75 | - public function resetConfiguration() |
|
| 76 | - { |
|
| 77 | - LoggerManager::resetConfiguration(); |
|
| 78 | - } |
|
| 65 | + /** |
|
| 66 | + * Reset the default hierarchy to its defaut. |
|
| 67 | + * It is equivalent to |
|
| 68 | + * <code> |
|
| 69 | + * LoggerManager::resetConfiguration(); |
|
| 70 | + * </code> |
|
| 71 | + * |
|
| 72 | + * @see LoggerHierarchy::resetConfiguration() |
|
| 73 | + * @static |
|
| 74 | + */ |
|
| 75 | + public function resetConfiguration() |
|
| 76 | + { |
|
| 77 | + LoggerManager::resetConfiguration(); |
|
| 78 | + } |
|
| 79 | 79 | } |
| 80 | 80 | ?> |
@@ -51,79 +51,79 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | class LoggerMDC { |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Put a context value as identified with the key parameter into the current thread's |
|
| 56 | - * context map. |
|
| 57 | - * |
|
| 58 | - * <p>If the current thread does not have a context map it is |
|
| 59 | - * created as a side effect.</p> |
|
| 60 | - * |
|
| 61 | - * <p>Note that you cannot put more than {@link LOGGER_MDC_HT_SIZE} keys.</p> |
|
| 62 | - * |
|
| 63 | - * @param string $key the key |
|
| 64 | - * @param string $value the value |
|
| 65 | - * @static |
|
| 66 | - */ |
|
| 67 | - public function put($key, $value) |
|
| 68 | - { |
|
| 69 | - if ( sizeof($GLOBALS['log4php.LoggerMDC.ht']) < LOGGER_MDC_HT_SIZE ) |
|
| 70 | - $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value; |
|
| 71 | - } |
|
| 54 | + /** |
|
| 55 | + * Put a context value as identified with the key parameter into the current thread's |
|
| 56 | + * context map. |
|
| 57 | + * |
|
| 58 | + * <p>If the current thread does not have a context map it is |
|
| 59 | + * created as a side effect.</p> |
|
| 60 | + * |
|
| 61 | + * <p>Note that you cannot put more than {@link LOGGER_MDC_HT_SIZE} keys.</p> |
|
| 62 | + * |
|
| 63 | + * @param string $key the key |
|
| 64 | + * @param string $value the value |
|
| 65 | + * @static |
|
| 66 | + */ |
|
| 67 | + public function put($key, $value) |
|
| 68 | + { |
|
| 69 | + if ( sizeof($GLOBALS['log4php.LoggerMDC.ht']) < LOGGER_MDC_HT_SIZE ) |
|
| 70 | + $GLOBALS['log4php.LoggerMDC.ht'][$key] = $value; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Get the context identified by the key parameter. |
|
| 75 | - * |
|
| 76 | - * <p>You can use special key identifiers to map values in |
|
| 77 | - * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.' |
|
| 78 | - * followed by the var name you want to refer.</p> |
|
| 79 | - * |
|
| 80 | - * <p>This method has no side effects.</p> |
|
| 81 | - * |
|
| 82 | - * @param string $key |
|
| 83 | - * @return string |
|
| 84 | - * @static |
|
| 85 | - */ |
|
| 86 | - public function get($key) |
|
| 87 | - { |
|
| 88 | - LoggerLog::debug("LoggerMDC::get() key='$key'"); |
|
| 73 | + /** |
|
| 74 | + * Get the context identified by the key parameter. |
|
| 75 | + * |
|
| 76 | + * <p>You can use special key identifiers to map values in |
|
| 77 | + * PHP $_SERVER and $_ENV vars. Just put a 'server.' or 'env.' |
|
| 78 | + * followed by the var name you want to refer.</p> |
|
| 79 | + * |
|
| 80 | + * <p>This method has no side effects.</p> |
|
| 81 | + * |
|
| 82 | + * @param string $key |
|
| 83 | + * @return string |
|
| 84 | + * @static |
|
| 85 | + */ |
|
| 86 | + public function get($key) |
|
| 87 | + { |
|
| 88 | + LoggerLog::debug("LoggerMDC::get() key='$key'"); |
|
| 89 | 89 | |
| 90 | - if (!empty($key)) { |
|
| 91 | - if (strpos($key, 'server.') === 0) { |
|
| 92 | - $varName = substr($key, 7); |
|
| 90 | + if (!empty($key)) { |
|
| 91 | + if (strpos($key, 'server.') === 0) { |
|
| 92 | + $varName = substr($key, 7); |
|
| 93 | 93 | |
| 94 | - LoggerLog::debug("LoggerMDC::get() a _SERVER[$varName] is requested."); |
|
| 94 | + LoggerLog::debug("LoggerMDC::get() a _SERVER[$varName] is requested."); |
|
| 95 | 95 | |
| 96 | - return $_SERVER[$varName]; |
|
| 97 | - } elseif (strpos($key, 'env.') === 0) { |
|
| 96 | + return $_SERVER[$varName]; |
|
| 97 | + } elseif (strpos($key, 'env.') === 0) { |
|
| 98 | 98 | |
| 99 | - $varName = substr($key, 4); |
|
| 99 | + $varName = substr($key, 4); |
|
| 100 | 100 | |
| 101 | - LoggerLog::debug("LoggerMDC::get() a _ENV[$varName] is requested."); |
|
| 101 | + LoggerLog::debug("LoggerMDC::get() a _ENV[$varName] is requested."); |
|
| 102 | 102 | |
| 103 | - return $_ENV[$varName]; |
|
| 104 | - } elseif (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) { |
|
| 103 | + return $_ENV[$varName]; |
|
| 104 | + } elseif (isset($GLOBALS['log4php.LoggerMDC.ht'][$key])) { |
|
| 105 | 105 | |
| 106 | - LoggerLog::debug("LoggerMDC::get() a user key is requested."); |
|
| 106 | + LoggerLog::debug("LoggerMDC::get() a user key is requested."); |
|
| 107 | 107 | |
| 108 | - return $GLOBALS['log4php.LoggerMDC.ht'][$key]; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - return ''; |
|
| 112 | - } |
|
| 108 | + return $GLOBALS['log4php.LoggerMDC.ht'][$key]; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + return ''; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Remove the the context identified by the key parameter. |
|
| 116 | - * |
|
| 117 | - * It only affects user mappings. |
|
| 118 | - * |
|
| 119 | - * @param string $key |
|
| 120 | - * @return string |
|
| 121 | - * @static |
|
| 122 | - */ |
|
| 123 | - public function remove($key) |
|
| 124 | - { |
|
| 125 | - unset($GLOBALS['log4php.LoggerMDC.ht'][$key]); |
|
| 126 | - } |
|
| 114 | + /** |
|
| 115 | + * Remove the the context identified by the key parameter. |
|
| 116 | + * |
|
| 117 | + * It only affects user mappings. |
|
| 118 | + * |
|
| 119 | + * @param string $key |
|
| 120 | + * @return string |
|
| 121 | + * @static |
|
| 122 | + */ |
|
| 123 | + public function remove($key) |
|
| 124 | + { |
|
| 125 | + unset($GLOBALS['log4php.LoggerMDC.ht'][$key]); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | ?> |
| 130 | 130 | \ No newline at end of file |
@@ -36,66 +36,66 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class LoggerRoot extends Logger { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var string name of logger |
|
| 41 | - */ |
|
| 42 | - var $name = 'root'; |
|
| 39 | + /** |
|
| 40 | + * @var string name of logger |
|
| 41 | + */ |
|
| 42 | + var $name = 'root'; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var object must be null for LoggerRoot |
|
| 46 | - */ |
|
| 47 | - var $parent = null; |
|
| 44 | + /** |
|
| 45 | + * @var object must be null for LoggerRoot |
|
| 46 | + */ |
|
| 47 | + var $parent = null; |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Constructor |
|
| 52 | - * |
|
| 53 | - * @param integer $level initial log level |
|
| 54 | - */ |
|
| 55 | - public function LoggerRoot($level = null) |
|
| 56 | - { |
|
| 57 | - $this->Logger($this->name); |
|
| 58 | - if ($level == null) |
|
| 59 | - $level = LoggerLevel::getLevelAll(); |
|
| 60 | - $this->setLevel($level); |
|
| 61 | - } |
|
| 50 | + /** |
|
| 51 | + * Constructor |
|
| 52 | + * |
|
| 53 | + * @param integer $level initial log level |
|
| 54 | + */ |
|
| 55 | + public function LoggerRoot($level = null) |
|
| 56 | + { |
|
| 57 | + $this->Logger($this->name); |
|
| 58 | + if ($level == null) |
|
| 59 | + $level = LoggerLevel::getLevelAll(); |
|
| 60 | + $this->setLevel($level); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @return integer the level |
|
| 65 | - */ |
|
| 66 | - public function getChainedLevel() |
|
| 67 | - { |
|
| 68 | - return $this->level; |
|
| 69 | - } |
|
| 63 | + /** |
|
| 64 | + * @return integer the level |
|
| 65 | + */ |
|
| 66 | + public function getChainedLevel() |
|
| 67 | + { |
|
| 68 | + return $this->level; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Setting a null value to the level of the root category may have catastrophic results. |
|
| 73 | - * @param LoggerLevel $level |
|
| 74 | - */ |
|
| 75 | - public function setLevel($level) |
|
| 76 | - { |
|
| 77 | - $this->level = $level; |
|
| 78 | - } |
|
| 71 | + /** |
|
| 72 | + * Setting a null value to the level of the root category may have catastrophic results. |
|
| 73 | + * @param LoggerLevel $level |
|
| 74 | + */ |
|
| 75 | + public function setLevel($level) |
|
| 76 | + { |
|
| 77 | + $this->level = $level; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Please use setLevel() instead. |
|
| 82 | - * @param LoggerLevel $level |
|
| 83 | - * @deprecated |
|
| 84 | - */ |
|
| 85 | - public function setPriority($level) |
|
| 86 | - { |
|
| 87 | - $this->setLevel($level); |
|
| 88 | - } |
|
| 80 | + /** |
|
| 81 | + * Please use setLevel() instead. |
|
| 82 | + * @param LoggerLevel $level |
|
| 83 | + * @deprecated |
|
| 84 | + */ |
|
| 85 | + public function setPriority($level) |
|
| 86 | + { |
|
| 87 | + $this->setLevel($level); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Always returns false. |
|
| 92 | - * Because LoggerRoot has no parents, it returns false. |
|
| 93 | - * @param Logger $parent |
|
| 94 | - * @return boolean |
|
| 95 | - */ |
|
| 96 | - public function setParent($parent) |
|
| 97 | - { |
|
| 98 | - return false; |
|
| 99 | - } |
|
| 90 | + /** |
|
| 91 | + * Always returns false. |
|
| 92 | + * Because LoggerRoot has no parents, it returns false. |
|
| 93 | + * @param Logger $parent |
|
| 94 | + * @return boolean |
|
| 95 | + */ |
|
| 96 | + public function setParent($parent) |
|
| 97 | + { |
|
| 98 | + return false; |
|
| 99 | + } |
|
| 100 | 100 | } |
| 101 | 101 | ?> |
| 102 | 102 | \ No newline at end of file |
@@ -41,315 +41,315 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | class LoggerAppenderSkeleton extends LoggerAppender { |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var boolean closed appender flag |
|
| 46 | - */ |
|
| 47 | - var $closed; |
|
| 44 | + /** |
|
| 45 | + * @var boolean closed appender flag |
|
| 46 | + */ |
|
| 47 | + var $closed; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var object unused |
|
| 51 | - */ |
|
| 52 | - var $errorHandler; |
|
| 49 | + /** |
|
| 50 | + * @var object unused |
|
| 51 | + */ |
|
| 52 | + var $errorHandler; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * The first filter in the filter chain |
|
| 56 | - * @var LoggerFilter |
|
| 57 | - */ |
|
| 58 | - var $headFilter = null; |
|
| 54 | + /** |
|
| 55 | + * The first filter in the filter chain |
|
| 56 | + * @var LoggerFilter |
|
| 57 | + */ |
|
| 58 | + var $headFilter = null; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * LoggerLayout for this appender. It can be null if appender has its own layout |
|
| 62 | - * @var LoggerLayout |
|
| 63 | - */ |
|
| 64 | - var $layout = null; |
|
| 60 | + /** |
|
| 61 | + * LoggerLayout for this appender. It can be null if appender has its own layout |
|
| 62 | + * @var LoggerLayout |
|
| 63 | + */ |
|
| 64 | + var $layout = null; |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @var string Appender name |
|
| 68 | - */ |
|
| 69 | - var $name; |
|
| 66 | + /** |
|
| 67 | + * @var string Appender name |
|
| 68 | + */ |
|
| 69 | + var $name; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * The last filter in the filter chain |
|
| 73 | - * @var LoggerFilter |
|
| 74 | - */ |
|
| 75 | - var $tailFilter = null; |
|
| 71 | + /** |
|
| 72 | + * The last filter in the filter chain |
|
| 73 | + * @var LoggerFilter |
|
| 74 | + */ |
|
| 75 | + var $tailFilter = null; |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @var LoggerLevel There is no level threshold filtering by default. |
|
| 79 | - */ |
|
| 80 | - var $threshold = null; |
|
| 77 | + /** |
|
| 78 | + * @var LoggerLevel There is no level threshold filtering by default. |
|
| 79 | + */ |
|
| 80 | + var $threshold = null; |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @var boolean needs a layout formatting ? |
|
| 84 | - */ |
|
| 85 | - var $requiresLayout = false; |
|
| 82 | + /** |
|
| 83 | + * @var boolean needs a layout formatting ? |
|
| 84 | + */ |
|
| 85 | + var $requiresLayout = false; |
|
| 86 | 86 | |
| 87 | 87 | /* --------------------------------------------------------------------------*/ |
| 88 | 88 | /* --------------------------------------------------------------------------*/ |
| 89 | 89 | /* --------------------------------------------------------------------------*/ |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Constructor |
|
| 93 | - * |
|
| 94 | - * @param string $name appender name |
|
| 95 | - */ |
|
| 96 | - public function LoggerAppenderSkeleton($name) |
|
| 97 | - { |
|
| 98 | - $this->name = $name; |
|
| 99 | - $this->clearFilters(); |
|
| 100 | - } |
|
| 91 | + /** |
|
| 92 | + * Constructor |
|
| 93 | + * |
|
| 94 | + * @param string $name appender name |
|
| 95 | + */ |
|
| 96 | + public function LoggerAppenderSkeleton($name) |
|
| 97 | + { |
|
| 98 | + $this->name = $name; |
|
| 99 | + $this->clearFilters(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * @param LoggerFilter $newFilter add a new LoggerFilter |
|
| 104 | - * @see LoggerAppender::addFilter() |
|
| 105 | - */ |
|
| 106 | - public function addFilter($newFilter) |
|
| 107 | - { |
|
| 108 | - if($this->headFilter === null) { |
|
| 109 | - $this->headFilter = $newFilter; |
|
| 110 | - $this->tailFilter =& $this->headFilter; |
|
| 111 | - } else { |
|
| 112 | - $this->tailFilter->next = $newFilter; |
|
| 113 | - $this->tailFilter =& $this->tailFilter->next; |
|
| 114 | - } |
|
| 115 | - } |
|
| 102 | + /** |
|
| 103 | + * @param LoggerFilter $newFilter add a new LoggerFilter |
|
| 104 | + * @see LoggerAppender::addFilter() |
|
| 105 | + */ |
|
| 106 | + public function addFilter($newFilter) |
|
| 107 | + { |
|
| 108 | + if($this->headFilter === null) { |
|
| 109 | + $this->headFilter = $newFilter; |
|
| 110 | + $this->tailFilter =& $this->headFilter; |
|
| 111 | + } else { |
|
| 112 | + $this->tailFilter->next = $newFilter; |
|
| 113 | + $this->tailFilter =& $this->tailFilter->next; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Derived appenders should override this method if option structure |
|
| 119 | - * requires it. |
|
| 120 | - */ |
|
| 121 | - public function activateOptions() |
|
| 122 | - { |
|
| 117 | + /** |
|
| 118 | + * Derived appenders should override this method if option structure |
|
| 119 | + * requires it. |
|
| 120 | + */ |
|
| 121 | + public function activateOptions() |
|
| 122 | + { |
|
| 123 | 123 | |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Subclasses of {@link LoggerAppenderSkeleton} should implement |
|
| 128 | - * this method to perform actual logging. |
|
| 129 | - * |
|
| 130 | - * @param LoggerLoggingEvent $event |
|
| 131 | - * @see doAppend() |
|
| 132 | - * @abstract |
|
| 133 | - */ |
|
| 134 | - public function append($event) |
|
| 135 | - { |
|
| 136 | - // override me |
|
| 137 | - } |
|
| 126 | + /** |
|
| 127 | + * Subclasses of {@link LoggerAppenderSkeleton} should implement |
|
| 128 | + * this method to perform actual logging. |
|
| 129 | + * |
|
| 130 | + * @param LoggerLoggingEvent $event |
|
| 131 | + * @see doAppend() |
|
| 132 | + * @abstract |
|
| 133 | + */ |
|
| 134 | + public function append($event) |
|
| 135 | + { |
|
| 136 | + // override me |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * @see LoggerAppender::clearFilters() |
|
| 141 | - */ |
|
| 142 | - public function clearFilters() |
|
| 143 | - { |
|
| 144 | - unset($this->headFilter); |
|
| 145 | - unset($this->tailFilter); |
|
| 146 | - $this->headFilter = null; |
|
| 147 | - $this->tailFilter = null; |
|
| 148 | - } |
|
| 139 | + /** |
|
| 140 | + * @see LoggerAppender::clearFilters() |
|
| 141 | + */ |
|
| 142 | + public function clearFilters() |
|
| 143 | + { |
|
| 144 | + unset($this->headFilter); |
|
| 145 | + unset($this->tailFilter); |
|
| 146 | + $this->headFilter = null; |
|
| 147 | + $this->tailFilter = null; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * @see LoggerAppender::close() |
|
| 152 | - */ |
|
| 153 | - public function close() |
|
| 154 | - { |
|
| 155 | - //override me |
|
| 156 | - } |
|
| 150 | + /** |
|
| 151 | + * @see LoggerAppender::close() |
|
| 152 | + */ |
|
| 153 | + public function close() |
|
| 154 | + { |
|
| 155 | + //override me |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Finalize this appender by calling the derived class' <i>close()</i> method. |
|
| 160 | - */ |
|
| 161 | - public function finalize() |
|
| 162 | - { |
|
| 163 | - // An appender might be closed then garbage collected. There is no |
|
| 164 | - // point in closing twice. |
|
| 165 | - if ($this->closed) return; |
|
| 158 | + /** |
|
| 159 | + * Finalize this appender by calling the derived class' <i>close()</i> method. |
|
| 160 | + */ |
|
| 161 | + public function finalize() |
|
| 162 | + { |
|
| 163 | + // An appender might be closed then garbage collected. There is no |
|
| 164 | + // point in closing twice. |
|
| 165 | + if ($this->closed) return; |
|
| 166 | 166 | |
| 167 | - LoggerLog::debug("LoggerAppenderSkeleton::finalize():name=[{$this->name}]."); |
|
| 167 | + LoggerLog::debug("LoggerAppenderSkeleton::finalize():name=[{$this->name}]."); |
|
| 168 | 168 | |
| 169 | - $this->close(); |
|
| 170 | - } |
|
| 169 | + $this->close(); |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Do not use this method. |
|
| 174 | - * @see LoggerAppender::getErrorHandler() |
|
| 175 | - * @return object |
|
| 176 | - */ |
|
| 177 | - public function &getErrorHandler() |
|
| 178 | - { |
|
| 179 | - return $this->errorHandler; |
|
| 180 | - } |
|
| 172 | + /** |
|
| 173 | + * Do not use this method. |
|
| 174 | + * @see LoggerAppender::getErrorHandler() |
|
| 175 | + * @return object |
|
| 176 | + */ |
|
| 177 | + public function &getErrorHandler() |
|
| 178 | + { |
|
| 179 | + return $this->errorHandler; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * @see LoggerAppender::getFilter() |
|
| 184 | - * @return Filter |
|
| 185 | - */ |
|
| 186 | - public function &getFilter() |
|
| 187 | - { |
|
| 188 | - return $this->headFilter; |
|
| 189 | - } |
|
| 182 | + /** |
|
| 183 | + * @see LoggerAppender::getFilter() |
|
| 184 | + * @return Filter |
|
| 185 | + */ |
|
| 186 | + public function &getFilter() |
|
| 187 | + { |
|
| 188 | + return $this->headFilter; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Return the first filter in the filter chain for this Appender. |
|
| 193 | - * The return value may be <i>null</i> if no is filter is set. |
|
| 194 | - * @return Filter |
|
| 195 | - */ |
|
| 196 | - public function &getFirstFilter() |
|
| 197 | - { |
|
| 198 | - return $this->headFilter; |
|
| 199 | - } |
|
| 191 | + /** |
|
| 192 | + * Return the first filter in the filter chain for this Appender. |
|
| 193 | + * The return value may be <i>null</i> if no is filter is set. |
|
| 194 | + * @return Filter |
|
| 195 | + */ |
|
| 196 | + public function &getFirstFilter() |
|
| 197 | + { |
|
| 198 | + return $this->headFilter; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * @see LoggerAppender::getLayout() |
|
| 203 | - * @return LoggerLayout |
|
| 204 | - */ |
|
| 205 | - public function &getLayout() |
|
| 206 | - { |
|
| 207 | - return $this->layout; |
|
| 208 | - } |
|
| 201 | + /** |
|
| 202 | + * @see LoggerAppender::getLayout() |
|
| 203 | + * @return LoggerLayout |
|
| 204 | + */ |
|
| 205 | + public function &getLayout() |
|
| 206 | + { |
|
| 207 | + return $this->layout; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * @see LoggerAppender::getName() |
|
| 212 | - * @return string |
|
| 213 | - */ |
|
| 214 | - public function getName() |
|
| 215 | - { |
|
| 216 | - return $this->name; |
|
| 217 | - } |
|
| 210 | + /** |
|
| 211 | + * @see LoggerAppender::getName() |
|
| 212 | + * @return string |
|
| 213 | + */ |
|
| 214 | + public function getName() |
|
| 215 | + { |
|
| 216 | + return $this->name; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * Returns this appenders threshold level. |
|
| 221 | - * See the {@link setThreshold()} method for the meaning of this option. |
|
| 222 | - * @return LoggerLevel |
|
| 223 | - */ |
|
| 224 | - public function &getThreshold() |
|
| 225 | - { |
|
| 226 | - return $this->threshold; |
|
| 227 | - } |
|
| 219 | + /** |
|
| 220 | + * Returns this appenders threshold level. |
|
| 221 | + * See the {@link setThreshold()} method for the meaning of this option. |
|
| 222 | + * @return LoggerLevel |
|
| 223 | + */ |
|
| 224 | + public function &getThreshold() |
|
| 225 | + { |
|
| 226 | + return $this->threshold; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Check whether the message level is below the appender's threshold. |
|
| 231 | - * |
|
| 232 | - * |
|
| 233 | - * If there is no threshold set, then the return value is always <i>true</i>. |
|
| 234 | - * @param LoggerLevel $priority |
|
| 235 | - * @return boolean true if priority is greater or equal than threshold |
|
| 236 | - */ |
|
| 237 | - public function isAsSevereAsThreshold($priority) |
|
| 238 | - { |
|
| 239 | - if ($this->threshold === null) |
|
| 240 | - return true; |
|
| 229 | + /** |
|
| 230 | + * Check whether the message level is below the appender's threshold. |
|
| 231 | + * |
|
| 232 | + * |
|
| 233 | + * If there is no threshold set, then the return value is always <i>true</i>. |
|
| 234 | + * @param LoggerLevel $priority |
|
| 235 | + * @return boolean true if priority is greater or equal than threshold |
|
| 236 | + */ |
|
| 237 | + public function isAsSevereAsThreshold($priority) |
|
| 238 | + { |
|
| 239 | + if ($this->threshold === null) |
|
| 240 | + return true; |
|
| 241 | 241 | |
| 242 | - return $priority->isGreaterOrEqual($this->getThreshold()); |
|
| 243 | - } |
|
| 242 | + return $priority->isGreaterOrEqual($this->getThreshold()); |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * @see LoggerAppender::doAppend() |
|
| 247 | - * @param LoggerLoggingEvent $event |
|
| 248 | - */ |
|
| 249 | - public function doAppend($event) |
|
| 250 | - { |
|
| 251 | - LoggerLog::debug("LoggerAppenderSkeleton::doAppend()"); |
|
| 245 | + /** |
|
| 246 | + * @see LoggerAppender::doAppend() |
|
| 247 | + * @param LoggerLoggingEvent $event |
|
| 248 | + */ |
|
| 249 | + public function doAppend($event) |
|
| 250 | + { |
|
| 251 | + LoggerLog::debug("LoggerAppenderSkeleton::doAppend()"); |
|
| 252 | 252 | |
| 253 | - if ($this->closed) { |
|
| 254 | - LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}]."); |
|
| 255 | - return; |
|
| 256 | - } |
|
| 257 | - if(!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
| 258 | - LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold."); |
|
| 259 | - return; |
|
| 260 | - } |
|
| 253 | + if ($this->closed) { |
|
| 254 | + LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}]."); |
|
| 255 | + return; |
|
| 256 | + } |
|
| 257 | + if(!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
| 258 | + LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold."); |
|
| 259 | + return; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - $f = $this->getFirstFilter(); |
|
| 262 | + $f = $this->getFirstFilter(); |
|
| 263 | 263 | |
| 264 | - while($f !== null) { |
|
| 265 | - switch ($f->decide($event)) { |
|
| 266 | - case LOG4PHP_LOGGER_FILTER_DENY: return; |
|
| 267 | - case LOG4PHP_LOGGER_FILTER_ACCEPT: return $this->append($event); |
|
| 268 | - case LOG4PHP_LOGGER_FILTER_NEUTRAL: $f = $f->next; |
|
| 269 | - } |
|
| 270 | - } |
|
| 271 | - $this->append($event); |
|
| 272 | - } |
|
| 264 | + while($f !== null) { |
|
| 265 | + switch ($f->decide($event)) { |
|
| 266 | + case LOG4PHP_LOGGER_FILTER_DENY: return; |
|
| 267 | + case LOG4PHP_LOGGER_FILTER_ACCEPT: return $this->append($event); |
|
| 268 | + case LOG4PHP_LOGGER_FILTER_NEUTRAL: $f = $f->next; |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | + $this->append($event); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * @see LoggerAppender::requiresLayout() |
|
| 277 | - * @return boolean |
|
| 278 | - */ |
|
| 279 | - public function requiresLayout() |
|
| 280 | - { |
|
| 281 | - return $this->requiresLayout; |
|
| 282 | - } |
|
| 275 | + /** |
|
| 276 | + * @see LoggerAppender::requiresLayout() |
|
| 277 | + * @return boolean |
|
| 278 | + */ |
|
| 279 | + public function requiresLayout() |
|
| 280 | + { |
|
| 281 | + return $this->requiresLayout; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - /** |
|
| 285 | - * @see LoggerAppender::setErrorHandler() |
|
| 286 | - * @param object |
|
| 287 | - */ |
|
| 288 | - public function setErrorHandler($errorHandler) |
|
| 289 | - { |
|
| 290 | - if($errorHandler == null) { |
|
| 291 | - // We do not throw exception here since the cause is probably a |
|
| 292 | - // bad config file. |
|
| 293 | - LoggerLog::warn("You have tried to set a null error-handler."); |
|
| 294 | - } else { |
|
| 295 | - $this->errorHandler = $errorHandler; |
|
| 296 | - } |
|
| 297 | - } |
|
| 284 | + /** |
|
| 285 | + * @see LoggerAppender::setErrorHandler() |
|
| 286 | + * @param object |
|
| 287 | + */ |
|
| 288 | + public function setErrorHandler($errorHandler) |
|
| 289 | + { |
|
| 290 | + if($errorHandler == null) { |
|
| 291 | + // We do not throw exception here since the cause is probably a |
|
| 292 | + // bad config file. |
|
| 293 | + LoggerLog::warn("You have tried to set a null error-handler."); |
|
| 294 | + } else { |
|
| 295 | + $this->errorHandler = $errorHandler; |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - /** |
|
| 300 | - * @see LoggerAppender::setLayout() |
|
| 301 | - * @param LoggerLayout $layout |
|
| 302 | - */ |
|
| 303 | - public function setLayout($layout) |
|
| 304 | - { |
|
| 305 | - if ($this->requiresLayout()) |
|
| 306 | - $this->layout = $layout; |
|
| 307 | - } |
|
| 299 | + /** |
|
| 300 | + * @see LoggerAppender::setLayout() |
|
| 301 | + * @param LoggerLayout $layout |
|
| 302 | + */ |
|
| 303 | + public function setLayout($layout) |
|
| 304 | + { |
|
| 305 | + if ($this->requiresLayout()) |
|
| 306 | + $this->layout = $layout; |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - /** |
|
| 310 | - * @see LoggerAppender::setName() |
|
| 311 | - * @param string $name |
|
| 312 | - */ |
|
| 313 | - public function setName($name) |
|
| 314 | - { |
|
| 315 | - $this->name = $name; |
|
| 316 | - } |
|
| 309 | + /** |
|
| 310 | + * @see LoggerAppender::setName() |
|
| 311 | + * @param string $name |
|
| 312 | + */ |
|
| 313 | + public function setName($name) |
|
| 314 | + { |
|
| 315 | + $this->name = $name; |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | - /** |
|
| 319 | - * Set the threshold level of this appender. |
|
| 320 | - * |
|
| 321 | - * @param mixed $threshold can be a {@link LoggerLevel} object or a string. |
|
| 322 | - * @see LoggerOptionConverter::toLevel() |
|
| 323 | - */ |
|
| 324 | - public function setThreshold($threshold) |
|
| 325 | - { |
|
| 326 | - if (is_string($threshold)) { |
|
| 327 | - $this->threshold = LoggerOptionConverter::toLevel($threshold, null); |
|
| 328 | - }elseif (is_a($threshold, 'loggerlevel')) { |
|
| 329 | - $this->threshold = $threshold; |
|
| 330 | - } |
|
| 331 | - } |
|
| 318 | + /** |
|
| 319 | + * Set the threshold level of this appender. |
|
| 320 | + * |
|
| 321 | + * @param mixed $threshold can be a {@link LoggerLevel} object or a string. |
|
| 322 | + * @see LoggerOptionConverter::toLevel() |
|
| 323 | + */ |
|
| 324 | + public function setThreshold($threshold) |
|
| 325 | + { |
|
| 326 | + if (is_string($threshold)) { |
|
| 327 | + $this->threshold = LoggerOptionConverter::toLevel($threshold, null); |
|
| 328 | + }elseif (is_a($threshold, 'loggerlevel')) { |
|
| 329 | + $this->threshold = $threshold; |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - /** |
|
| 334 | - * Perform actions before object serialization. |
|
| 335 | - * |
|
| 336 | - * Call {@link finalize()} to properly close the appender. |
|
| 337 | - */ |
|
| 338 | - public function __sleep() |
|
| 339 | - { |
|
| 340 | - $this->finalize(); |
|
| 341 | - return array_keys(get_object_vars($this)); |
|
| 342 | - } |
|
| 333 | + /** |
|
| 334 | + * Perform actions before object serialization. |
|
| 335 | + * |
|
| 336 | + * Call {@link finalize()} to properly close the appender. |
|
| 337 | + */ |
|
| 338 | + public function __sleep() |
|
| 339 | + { |
|
| 340 | + $this->finalize(); |
|
| 341 | + return array_keys(get_object_vars($this)); |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - /** |
|
| 345 | - * Perform actions after object deserialization. |
|
| 346 | - * |
|
| 347 | - * Call {@link activateOptions()} to properly setup the appender. |
|
| 348 | - */ |
|
| 349 | - public function __wakeup() |
|
| 350 | - { |
|
| 351 | - $this->activateOptions(); |
|
| 352 | - } |
|
| 344 | + /** |
|
| 345 | + * Perform actions after object deserialization. |
|
| 346 | + * |
|
| 347 | + * Call {@link activateOptions()} to properly setup the appender. |
|
| 348 | + */ |
|
| 349 | + public function __wakeup() |
|
| 350 | + { |
|
| 351 | + $this->activateOptions(); |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | } |
| 355 | 355 | ?> |
| 356 | 356 | \ No newline at end of file |
@@ -34,30 +34,30 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | class LoggerObjectRenderer { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param string $class classname |
|
| 39 | - * @return LoggerObjectRenderer create LoggerObjectRenderer instances |
|
| 40 | - */ |
|
| 41 | - public function factory($class) |
|
| 42 | - { |
|
| 43 | - if (!empty($class)) { |
|
| 44 | - $class = basename($class); |
|
| 45 | - @include_once(LOG4PHP_DIR . "/or/{$class}.php"); |
|
| 46 | - if (class_exists($class)) { |
|
| 47 | - return new $class(); |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - return null; |
|
| 51 | - } |
|
| 37 | + /** |
|
| 38 | + * @param string $class classname |
|
| 39 | + * @return LoggerObjectRenderer create LoggerObjectRenderer instances |
|
| 40 | + */ |
|
| 41 | + public function factory($class) |
|
| 42 | + { |
|
| 43 | + if (!empty($class)) { |
|
| 44 | + $class = basename($class); |
|
| 45 | + @include_once(LOG4PHP_DIR . "/or/{$class}.php"); |
|
| 46 | + if (class_exists($class)) { |
|
| 47 | + return new $class(); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + return null; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Render the entity passed as parameter as a String. |
|
| 55 | - * @param mixed $o entity to render |
|
| 56 | - * @return string |
|
| 57 | - */ |
|
| 58 | - public function doRender($o) |
|
| 59 | - { |
|
| 60 | - // abstract |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Render the entity passed as parameter as a String. |
|
| 55 | + * @param mixed $o entity to render |
|
| 56 | + * @return string |
|
| 57 | + */ |
|
| 58 | + public function doRender($o) |
|
| 59 | + { |
|
| 60 | + // abstract |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | ?> |
| 64 | 64 | \ No newline at end of file |
@@ -39,146 +39,146 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | class LoggerRendererMap { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var array |
|
| 44 | - */ |
|
| 45 | - var $map; |
|
| 42 | + /** |
|
| 43 | + * @var array |
|
| 44 | + */ |
|
| 45 | + var $map; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var LoggerDefaultRenderer |
|
| 49 | - */ |
|
| 50 | - var $defaultRenderer; |
|
| 47 | + /** |
|
| 48 | + * @var LoggerDefaultRenderer |
|
| 49 | + */ |
|
| 50 | + var $defaultRenderer; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Constructor |
|
| 54 | - */ |
|
| 55 | - public function LoggerRendererMap() |
|
| 56 | - { |
|
| 57 | - $this->map = array(); |
|
| 58 | - $this->defaultRenderer = new LoggerDefaultRenderer(); |
|
| 59 | - } |
|
| 52 | + /** |
|
| 53 | + * Constructor |
|
| 54 | + */ |
|
| 55 | + public function LoggerRendererMap() |
|
| 56 | + { |
|
| 57 | + $this->map = array(); |
|
| 58 | + $this->defaultRenderer = new LoggerDefaultRenderer(); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Add a renderer to a hierarchy passed as parameter. |
|
| 63 | - * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
|
| 64 | - * |
|
| 65 | - * @param LoggerHierarchy &$repository a logger repository. |
|
| 66 | - * @param string &$renderedClassName |
|
| 67 | - * @param string &$renderingClassName |
|
| 68 | - * @static |
|
| 69 | - */ |
|
| 70 | - public function addRenderer(&$repository, $renderedClassName, $renderingClassName) |
|
| 71 | - { |
|
| 72 | - LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}]."); |
|
| 73 | - $renderer = LoggerObjectRenderer::factory($renderingClassName); |
|
| 74 | - if($renderer == null) { |
|
| 75 | - LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}]."); |
|
| 76 | - return; |
|
| 77 | - } else { |
|
| 78 | - $repository->setRenderer($renderedClassName, $renderer); |
|
| 79 | - } |
|
| 80 | - } |
|
| 61 | + /** |
|
| 62 | + * Add a renderer to a hierarchy passed as parameter. |
|
| 63 | + * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
|
| 64 | + * |
|
| 65 | + * @param LoggerHierarchy &$repository a logger repository. |
|
| 66 | + * @param string &$renderedClassName |
|
| 67 | + * @param string &$renderingClassName |
|
| 68 | + * @static |
|
| 69 | + */ |
|
| 70 | + public function addRenderer(&$repository, $renderedClassName, $renderingClassName) |
|
| 71 | + { |
|
| 72 | + LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}]."); |
|
| 73 | + $renderer = LoggerObjectRenderer::factory($renderingClassName); |
|
| 74 | + if($renderer == null) { |
|
| 75 | + LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}]."); |
|
| 76 | + return; |
|
| 77 | + } else { |
|
| 78 | + $repository->setRenderer($renderedClassName, $renderer); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Find the appropriate renderer for the class type of the |
|
| 85 | - * <var>o</var> parameter. |
|
| 86 | - * |
|
| 87 | - * This is accomplished by calling the {@link getByObject()} |
|
| 88 | - * method if <var>o</var> is object or using {@link LoggerDefaultRenderer}. |
|
| 89 | - * Once a renderer is found, it is applied on the object <var>o</var> and |
|
| 90 | - * the result is returned as a string. |
|
| 91 | - * |
|
| 92 | - * @param mixed $o |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 95 | - public function findAndRender($o) |
|
| 96 | - { |
|
| 97 | - if($o == null) { |
|
| 98 | - return null; |
|
| 99 | - } else { |
|
| 100 | - if (is_object($o)) { |
|
| 101 | - $renderer = $this->getByObject($o); |
|
| 102 | - if ($renderer !== null) { |
|
| 103 | - return $renderer->doRender($o); |
|
| 104 | - } else { |
|
| 105 | - return null; |
|
| 106 | - } |
|
| 107 | - } else { |
|
| 108 | - $renderer = $this->defaultRenderer; |
|
| 109 | - return $renderer->doRender($o); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 83 | + /** |
|
| 84 | + * Find the appropriate renderer for the class type of the |
|
| 85 | + * <var>o</var> parameter. |
|
| 86 | + * |
|
| 87 | + * This is accomplished by calling the {@link getByObject()} |
|
| 88 | + * method if <var>o</var> is object or using {@link LoggerDefaultRenderer}. |
|
| 89 | + * Once a renderer is found, it is applied on the object <var>o</var> and |
|
| 90 | + * the result is returned as a string. |
|
| 91 | + * |
|
| 92 | + * @param mixed $o |
|
| 93 | + * @return string |
|
| 94 | + */ |
|
| 95 | + public function findAndRender($o) |
|
| 96 | + { |
|
| 97 | + if($o == null) { |
|
| 98 | + return null; |
|
| 99 | + } else { |
|
| 100 | + if (is_object($o)) { |
|
| 101 | + $renderer = $this->getByObject($o); |
|
| 102 | + if ($renderer !== null) { |
|
| 103 | + return $renderer->doRender($o); |
|
| 104 | + } else { |
|
| 105 | + return null; |
|
| 106 | + } |
|
| 107 | + } else { |
|
| 108 | + $renderer = $this->defaultRenderer; |
|
| 109 | + return $renderer->doRender($o); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the |
|
| 116 | - * class of the object parameter. |
|
| 117 | - * |
|
| 118 | - * @param mixed $o |
|
| 119 | - * @return string |
|
| 120 | - */ |
|
| 121 | - public function &getByObject($o) |
|
| 122 | - { |
|
| 123 | - return ($o == null) ? null : $this->getByClassName(get_class($o)); |
|
| 124 | - } |
|
| 114 | + /** |
|
| 115 | + * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the |
|
| 116 | + * class of the object parameter. |
|
| 117 | + * |
|
| 118 | + * @param mixed $o |
|
| 119 | + * @return string |
|
| 120 | + */ |
|
| 121 | + public function &getByObject($o) |
|
| 122 | + { |
|
| 123 | + return ($o == null) ? null : $this->getByClassName(get_class($o)); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Search the parents of <var>clazz</var> for a renderer. |
|
| 129 | - * |
|
| 130 | - * The renderer closest in the hierarchy will be returned. If no |
|
| 131 | - * renderers could be found, then the default renderer is returned. |
|
| 132 | - * |
|
| 133 | - * @param string $class |
|
| 134 | - * @return LoggerObjectRenderer |
|
| 135 | - */ |
|
| 136 | - public function &getByClassName($class) |
|
| 137 | - { |
|
| 138 | - $r = null; |
|
| 139 | - for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
| 140 | - if (isset($this->map[$c])) { |
|
| 141 | - return $this->map[$c]; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - return $this->defaultRenderer; |
|
| 145 | - } |
|
| 127 | + /** |
|
| 128 | + * Search the parents of <var>clazz</var> for a renderer. |
|
| 129 | + * |
|
| 130 | + * The renderer closest in the hierarchy will be returned. If no |
|
| 131 | + * renderers could be found, then the default renderer is returned. |
|
| 132 | + * |
|
| 133 | + * @param string $class |
|
| 134 | + * @return LoggerObjectRenderer |
|
| 135 | + */ |
|
| 136 | + public function &getByClassName($class) |
|
| 137 | + { |
|
| 138 | + $r = null; |
|
| 139 | + for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
| 140 | + if (isset($this->map[$c])) { |
|
| 141 | + return $this->map[$c]; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + return $this->defaultRenderer; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * @return LoggerDefaultRenderer |
|
| 149 | - */ |
|
| 150 | - public function &getDefaultRenderer() |
|
| 151 | - { |
|
| 152 | - return $this->defaultRenderer; |
|
| 153 | - } |
|
| 147 | + /** |
|
| 148 | + * @return LoggerDefaultRenderer |
|
| 149 | + */ |
|
| 150 | + public function &getDefaultRenderer() |
|
| 151 | + { |
|
| 152 | + return $this->defaultRenderer; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | 155 | |
| 156 | - public function clear() |
|
| 157 | - { |
|
| 158 | - $this->map = array(); |
|
| 159 | - } |
|
| 156 | + public function clear() |
|
| 157 | + { |
|
| 158 | + $this->map = array(); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Register a {@link LoggerObjectRenderer} for <var>clazz</var>. |
|
| 163 | - * @param string $class |
|
| 164 | - * @param LoggerObjectRenderer $or |
|
| 165 | - */ |
|
| 166 | - public function put($class, $or) |
|
| 167 | - { |
|
| 168 | - $this->map[strtolower($class)] = $or; |
|
| 169 | - } |
|
| 161 | + /** |
|
| 162 | + * Register a {@link LoggerObjectRenderer} for <var>clazz</var>. |
|
| 163 | + * @param string $class |
|
| 164 | + * @param LoggerObjectRenderer $or |
|
| 165 | + */ |
|
| 166 | + public function put($class, $or) |
|
| 167 | + { |
|
| 168 | + $this->map[strtolower($class)] = $or; |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * @param string $class |
|
| 173 | - * @return boolean |
|
| 174 | - */ |
|
| 175 | - public function rendererExists($class) |
|
| 176 | - { |
|
| 177 | - $class = basename($class); |
|
| 178 | - if (!class_exists($class)) { |
|
| 179 | - @include_once(LOG4PHP_DIR ."/or/{$class}.php"); |
|
| 180 | - } |
|
| 181 | - return class_exists($class); |
|
| 182 | - } |
|
| 171 | + /** |
|
| 172 | + * @param string $class |
|
| 173 | + * @return boolean |
|
| 174 | + */ |
|
| 175 | + public function rendererExists($class) |
|
| 176 | + { |
|
| 177 | + $class = basename($class); |
|
| 178 | + if (!class_exists($class)) { |
|
| 179 | + @include_once(LOG4PHP_DIR ."/or/{$class}.php"); |
|
| 180 | + } |
|
| 181 | + return class_exists($class); |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | ?> |
| 185 | 185 | \ No newline at end of file |
@@ -36,23 +36,23 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class LoggerDefaultRenderer extends LoggerObjectRenderer{ |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Constructor |
|
| 41 | - */ |
|
| 42 | - public function LoggerDefaultRenderer() |
|
| 43 | - { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 39 | + /** |
|
| 40 | + * Constructor |
|
| 41 | + */ |
|
| 42 | + public function LoggerDefaultRenderer() |
|
| 43 | + { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Render objects by type casting |
|
| 49 | - * |
|
| 50 | - * @param mixed $o the object to render |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 53 | - public function doRender($o) |
|
| 54 | - { |
|
| 55 | - return var_export($o, true); |
|
| 56 | - } |
|
| 47 | + /** |
|
| 48 | + * Render objects by type casting |
|
| 49 | + * |
|
| 50 | + * @param mixed $o the object to render |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | + public function doRender($o) |
|
| 54 | + { |
|
| 55 | + return var_export($o, true); |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | ?> |
| 59 | 59 | \ No newline at end of file |
@@ -36,537 +36,537 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class LoggerCategory { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Additivity is set to true by default, that is children inherit the |
|
| 41 | - * appenders of their ancestors by default. |
|
| 42 | - * @var boolean |
|
| 43 | - */ |
|
| 44 | - var $additive = true; |
|
| 39 | + /** |
|
| 40 | + * Additivity is set to true by default, that is children inherit the |
|
| 41 | + * appenders of their ancestors by default. |
|
| 42 | + * @var boolean |
|
| 43 | + */ |
|
| 44 | + var $additive = true; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var string fully qualified class name |
|
| 48 | - */ |
|
| 49 | - var $fqcn = 'LoggerCategory'; |
|
| 46 | + /** |
|
| 47 | + * @var string fully qualified class name |
|
| 48 | + */ |
|
| 49 | + var $fqcn = 'LoggerCategory'; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var LoggerLevel The assigned level of this category. |
|
| 53 | - */ |
|
| 54 | - var $level = null; |
|
| 51 | + /** |
|
| 52 | + * @var LoggerLevel The assigned level of this category. |
|
| 53 | + */ |
|
| 54 | + var $level = null; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var string name of this category. |
|
| 58 | - */ |
|
| 59 | - var $name = ''; |
|
| 56 | + /** |
|
| 57 | + * @var string name of this category. |
|
| 58 | + */ |
|
| 59 | + var $name = ''; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var Logger The parent of this category. |
|
| 63 | - */ |
|
| 64 | - var $parent = null; |
|
| 61 | + /** |
|
| 62 | + * @var Logger The parent of this category. |
|
| 63 | + */ |
|
| 64 | + var $parent = null; |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @var LoggerHierarchy the object repository |
|
| 68 | - */ |
|
| 69 | - var $repository = null; |
|
| 66 | + /** |
|
| 67 | + * @var LoggerHierarchy the object repository |
|
| 68 | + */ |
|
| 69 | + var $repository = null; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @var array collection of appenders |
|
| 73 | - * @see LoggerAppender |
|
| 74 | - */ |
|
| 75 | - var $aai = array(); |
|
| 71 | + /** |
|
| 72 | + * @var array collection of appenders |
|
| 73 | + * @see LoggerAppender |
|
| 74 | + */ |
|
| 75 | + var $aai = array(); |
|
| 76 | 76 | |
| 77 | 77 | /* --------------------------------------------------------------------------*/ |
| 78 | 78 | /* --------------------------------------------------------------------------*/ |
| 79 | 79 | /* --------------------------------------------------------------------------*/ |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Constructor. |
|
| 83 | - * |
|
| 84 | - * @param string $name Category name |
|
| 85 | - */ |
|
| 86 | - public function LoggerCategory($name) |
|
| 87 | - { |
|
| 88 | - $this->name = $name; |
|
| 89 | - } |
|
| 81 | + /** |
|
| 82 | + * Constructor. |
|
| 83 | + * |
|
| 84 | + * @param string $name Category name |
|
| 85 | + */ |
|
| 86 | + public function LoggerCategory($name) |
|
| 87 | + { |
|
| 88 | + $this->name = $name; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Add a new Appender to the list of appenders of this Category instance. |
|
| 93 | - * |
|
| 94 | - * @param LoggerAppender $newAppender |
|
| 95 | - */ |
|
| 96 | - public function addAppender(&$newAppender) |
|
| 97 | - { |
|
| 98 | - $appenderName = $newAppender->getName(); |
|
| 99 | - $this->aai[$appenderName] =& $newAppender; |
|
| 100 | - } |
|
| 91 | + /** |
|
| 92 | + * Add a new Appender to the list of appenders of this Category instance. |
|
| 93 | + * |
|
| 94 | + * @param LoggerAppender $newAppender |
|
| 95 | + */ |
|
| 96 | + public function addAppender(&$newAppender) |
|
| 97 | + { |
|
| 98 | + $appenderName = $newAppender->getName(); |
|
| 99 | + $this->aai[$appenderName] =& $newAppender; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * If assertion parameter is false, then logs msg as an error statement. |
|
| 104 | - * |
|
| 105 | - * @param bool $assertion |
|
| 106 | - * @param string $msg message to log |
|
| 107 | - */ |
|
| 108 | - public function assertLog($assertion = true, $msg = '') |
|
| 109 | - { |
|
| 110 | - if ($assertion === false) { |
|
| 111 | - $this->error($msg); |
|
| 112 | - } |
|
| 113 | - } |
|
| 102 | + /** |
|
| 103 | + * If assertion parameter is false, then logs msg as an error statement. |
|
| 104 | + * |
|
| 105 | + * @param bool $assertion |
|
| 106 | + * @param string $msg message to log |
|
| 107 | + */ |
|
| 108 | + public function assertLog($assertion = true, $msg = '') |
|
| 109 | + { |
|
| 110 | + if ($assertion === false) { |
|
| 111 | + $this->error($msg); |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Call the appenders in the hierarchy starting at this. |
|
| 117 | - * |
|
| 118 | - * @param LoggerLoggingEvent $event |
|
| 119 | - */ |
|
| 120 | - public function callAppenders($event) |
|
| 121 | - { |
|
| 122 | - if (sizeof($this->aai) > 0) { |
|
| 123 | - foreach (array_keys($this->aai) as $appenderName) { |
|
| 124 | - $this->aai[$appenderName]->doAppend($event); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - if ($this->parent != null && $this->getAdditivity()) { |
|
| 128 | - $this->parent->callAppenders($event); |
|
| 129 | - } |
|
| 130 | - } |
|
| 115 | + /** |
|
| 116 | + * Call the appenders in the hierarchy starting at this. |
|
| 117 | + * |
|
| 118 | + * @param LoggerLoggingEvent $event |
|
| 119 | + */ |
|
| 120 | + public function callAppenders($event) |
|
| 121 | + { |
|
| 122 | + if (sizeof($this->aai) > 0) { |
|
| 123 | + foreach (array_keys($this->aai) as $appenderName) { |
|
| 124 | + $this->aai[$appenderName]->doAppend($event); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + if ($this->parent != null && $this->getAdditivity()) { |
|
| 128 | + $this->parent->callAppenders($event); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Log a message object with the DEBUG level including the caller. |
|
| 134 | - * |
|
| 135 | - * @param mixed $message message |
|
| 136 | - * @param mixed $caller caller object or caller string id |
|
| 137 | - */ |
|
| 138 | - public function debug($message, $caller = null) |
|
| 139 | - { |
|
| 140 | - $debugLevel = LoggerLevel::getLevelDebug(); |
|
| 141 | - if ($this->repository->isDisabled($debugLevel)) { |
|
| 142 | - return; |
|
| 143 | - } |
|
| 144 | - if ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 145 | - $this->forcedLog($this->fqcn, $caller, $debugLevel, $message); |
|
| 146 | - } |
|
| 147 | - } |
|
| 132 | + /** |
|
| 133 | + * Log a message object with the DEBUG level including the caller. |
|
| 134 | + * |
|
| 135 | + * @param mixed $message message |
|
| 136 | + * @param mixed $caller caller object or caller string id |
|
| 137 | + */ |
|
| 138 | + public function debug($message, $caller = null) |
|
| 139 | + { |
|
| 140 | + $debugLevel = LoggerLevel::getLevelDebug(); |
|
| 141 | + if ($this->repository->isDisabled($debugLevel)) { |
|
| 142 | + return; |
|
| 143 | + } |
|
| 144 | + if ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 145 | + $this->forcedLog($this->fqcn, $caller, $debugLevel, $message); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Log a message object with the ERROR level including the caller. |
|
| 151 | - * |
|
| 152 | - * @param mixed $message message |
|
| 153 | - * @param mixed $caller caller object or caller string id |
|
| 154 | - */ |
|
| 155 | - public function error($message, $caller = null) |
|
| 156 | - { |
|
| 157 | - $errorLevel = LoggerLevel::getLevelError(); |
|
| 158 | - if ($this->repository->isDisabled($errorLevel)) { |
|
| 159 | - return; |
|
| 160 | - } |
|
| 161 | - if ($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 162 | - $this->forcedLog($this->fqcn, $caller, $errorLevel, $message); |
|
| 149 | + /** |
|
| 150 | + * Log a message object with the ERROR level including the caller. |
|
| 151 | + * |
|
| 152 | + * @param mixed $message message |
|
| 153 | + * @param mixed $caller caller object or caller string id |
|
| 154 | + */ |
|
| 155 | + public function error($message, $caller = null) |
|
| 156 | + { |
|
| 157 | + $errorLevel = LoggerLevel::getLevelError(); |
|
| 158 | + if ($this->repository->isDisabled($errorLevel)) { |
|
| 159 | + return; |
|
| 160 | + } |
|
| 161 | + if ($errorLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 162 | + $this->forcedLog($this->fqcn, $caller, $errorLevel, $message); |
|
| 163 | 163 | $this->forcedLog($this->fqcn, $caller, $errorLevel, PHP_EOL.vtlib\Functions::getBacktrace(1)); |
| 164 | - } |
|
| 165 | - } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Deprecated. Please use LoggerManager::exists() instead. |
|
| 169 | - * |
|
| 170 | - * @param string $name |
|
| 171 | - * @see LoggerManager::exists() |
|
| 172 | - * @deprecated |
|
| 173 | - */ |
|
| 174 | - public function exists($name) |
|
| 175 | - { |
|
| 176 | - return LoggerManager::exists($name); |
|
| 177 | - } |
|
| 167 | + /** |
|
| 168 | + * Deprecated. Please use LoggerManager::exists() instead. |
|
| 169 | + * |
|
| 170 | + * @param string $name |
|
| 171 | + * @see LoggerManager::exists() |
|
| 172 | + * @deprecated |
|
| 173 | + */ |
|
| 174 | + public function exists($name) |
|
| 175 | + { |
|
| 176 | + return LoggerManager::exists($name); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Log a message object with the FATAL level including the caller. |
|
| 181 | - * |
|
| 182 | - * @param mixed $message message |
|
| 183 | - * @param mixed $caller caller object or caller string id |
|
| 184 | - */ |
|
| 185 | - public function fatal($message, $caller = null) |
|
| 186 | - { |
|
| 187 | - $fatalLevel = LoggerLevel::getLevelFatal(); |
|
| 188 | - if ($this->repository->isDisabled($fatalLevel)) { |
|
| 189 | - return; |
|
| 190 | - } |
|
| 191 | - if ($fatalLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 192 | - $this->forcedLog($this->fqcn, $caller, $fatalLevel, $message); |
|
| 193 | - } |
|
| 194 | - } |
|
| 179 | + /** |
|
| 180 | + * Log a message object with the FATAL level including the caller. |
|
| 181 | + * |
|
| 182 | + * @param mixed $message message |
|
| 183 | + * @param mixed $caller caller object or caller string id |
|
| 184 | + */ |
|
| 185 | + public function fatal($message, $caller = null) |
|
| 186 | + { |
|
| 187 | + $fatalLevel = LoggerLevel::getLevelFatal(); |
|
| 188 | + if ($this->repository->isDisabled($fatalLevel)) { |
|
| 189 | + return; |
|
| 190 | + } |
|
| 191 | + if ($fatalLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 192 | + $this->forcedLog($this->fqcn, $caller, $fatalLevel, $message); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * This method creates a new logging event and logs the event without further checks. |
|
| 198 | - * |
|
| 199 | - * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()}, |
|
| 200 | - * {@link error()} and {@link fatal()} wrappers. |
|
| 201 | - * |
|
| 202 | - * @param string $fqcn Fully Qualified Class Name of the Logger |
|
| 203 | - * @param mixed $caller caller object or caller string id |
|
| 204 | - * @param LoggerLevel $level log level |
|
| 205 | - * @param mixed $message message |
|
| 206 | - * @see LoggerLoggingEvent |
|
| 207 | - */ |
|
| 208 | - public function forcedLog($fqcn, $caller, $level, $message) |
|
| 209 | - { |
|
| 210 | - $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message)); |
|
| 211 | - } |
|
| 196 | + /** |
|
| 197 | + * This method creates a new logging event and logs the event without further checks. |
|
| 198 | + * |
|
| 199 | + * It should not be called directly. Use {@link info()}, {@link debug()}, {@link warn()}, |
|
| 200 | + * {@link error()} and {@link fatal()} wrappers. |
|
| 201 | + * |
|
| 202 | + * @param string $fqcn Fully Qualified Class Name of the Logger |
|
| 203 | + * @param mixed $caller caller object or caller string id |
|
| 204 | + * @param LoggerLevel $level log level |
|
| 205 | + * @param mixed $message message |
|
| 206 | + * @see LoggerLoggingEvent |
|
| 207 | + */ |
|
| 208 | + public function forcedLog($fqcn, $caller, $level, $message) |
|
| 209 | + { |
|
| 210 | + $this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message)); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * Get the additivity flag for this Category instance. |
|
| 215 | - * @return boolean |
|
| 216 | - */ |
|
| 217 | - public function getAdditivity() |
|
| 218 | - { |
|
| 219 | - return $this->additive; |
|
| 220 | - } |
|
| 213 | + /** |
|
| 214 | + * Get the additivity flag for this Category instance. |
|
| 215 | + * @return boolean |
|
| 216 | + */ |
|
| 217 | + public function getAdditivity() |
|
| 218 | + { |
|
| 219 | + return $this->additive; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Get the appenders contained in this category as an array. |
|
| 224 | - * @return array collection of appenders |
|
| 225 | - */ |
|
| 226 | - public function &getAllAppenders() |
|
| 227 | - { |
|
| 228 | - $appenders = array(); |
|
| 229 | - $appenderNames = array_keys($this->aai); |
|
| 230 | - $enumAppenders = sizeof($appenderNames); |
|
| 231 | - for ($i = 0; $i < $enumAppenders; $i++) { |
|
| 232 | - $appenderName = $appenderNames[$i]; |
|
| 233 | - $appenders[] =& $this->aai[$appenderName]; |
|
| 234 | - } |
|
| 235 | - return $appenders; |
|
| 236 | - } |
|
| 222 | + /** |
|
| 223 | + * Get the appenders contained in this category as an array. |
|
| 224 | + * @return array collection of appenders |
|
| 225 | + */ |
|
| 226 | + public function &getAllAppenders() |
|
| 227 | + { |
|
| 228 | + $appenders = array(); |
|
| 229 | + $appenderNames = array_keys($this->aai); |
|
| 230 | + $enumAppenders = sizeof($appenderNames); |
|
| 231 | + for ($i = 0; $i < $enumAppenders; $i++) { |
|
| 232 | + $appenderName = $appenderNames[$i]; |
|
| 233 | + $appenders[] =& $this->aai[$appenderName]; |
|
| 234 | + } |
|
| 235 | + return $appenders; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Look for the appender named as name. |
|
| 240 | - * @return LoggerAppender |
|
| 241 | - */ |
|
| 242 | - public function &getAppender($name) |
|
| 243 | - { |
|
| 244 | - return $this->aai[$name]; |
|
| 245 | - } |
|
| 238 | + /** |
|
| 239 | + * Look for the appender named as name. |
|
| 240 | + * @return LoggerAppender |
|
| 241 | + */ |
|
| 242 | + public function &getAppender($name) |
|
| 243 | + { |
|
| 244 | + return $this->aai[$name]; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - /** |
|
| 248 | - * Please use the {@link getEffectiveLevel()} method instead. |
|
| 249 | - * @deprecated |
|
| 250 | - */ |
|
| 251 | - public function getChainedPriority() |
|
| 252 | - { |
|
| 253 | - return $this->getEffectiveLevel(); |
|
| 254 | - } |
|
| 247 | + /** |
|
| 248 | + * Please use the {@link getEffectiveLevel()} method instead. |
|
| 249 | + * @deprecated |
|
| 250 | + */ |
|
| 251 | + public function getChainedPriority() |
|
| 252 | + { |
|
| 253 | + return $this->getEffectiveLevel(); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * Please use {@link LoggerManager::getCurrentLoggers()} instead. |
|
| 258 | - * @deprecated |
|
| 259 | - */ |
|
| 260 | - public function getCurrentCategories() |
|
| 261 | - { |
|
| 262 | - return LoggerManager::getCurrentLoggers(); |
|
| 263 | - } |
|
| 256 | + /** |
|
| 257 | + * Please use {@link LoggerManager::getCurrentLoggers()} instead. |
|
| 258 | + * @deprecated |
|
| 259 | + */ |
|
| 260 | + public function getCurrentCategories() |
|
| 261 | + { |
|
| 262 | + return LoggerManager::getCurrentLoggers(); |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - /** |
|
| 266 | - * Please use {@link LoggerManager::getLoggerRepository()} instead. |
|
| 267 | - * @deprecated |
|
| 268 | - */ |
|
| 269 | - public function &getDefaultHierarchy() |
|
| 270 | - { |
|
| 271 | - return LoggerManager::getLoggerRepository(); |
|
| 272 | - } |
|
| 265 | + /** |
|
| 266 | + * Please use {@link LoggerManager::getLoggerRepository()} instead. |
|
| 267 | + * @deprecated |
|
| 268 | + */ |
|
| 269 | + public function &getDefaultHierarchy() |
|
| 270 | + { |
|
| 271 | + return LoggerManager::getLoggerRepository(); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * @deprecated Use {@link getLoggerRepository()} |
|
| 276 | - * @return LoggerHierarchy |
|
| 277 | - */ |
|
| 278 | - public function &getHierarchy() |
|
| 279 | - { |
|
| 280 | - return $this->getLoggerRepository(); |
|
| 281 | - } |
|
| 274 | + /** |
|
| 275 | + * @deprecated Use {@link getLoggerRepository()} |
|
| 276 | + * @return LoggerHierarchy |
|
| 277 | + */ |
|
| 278 | + public function &getHierarchy() |
|
| 279 | + { |
|
| 280 | + return $this->getLoggerRepository(); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - /** |
|
| 284 | - * Starting from this category, search the category hierarchy for a non-null level and return it. |
|
| 285 | - * @see LoggerLevel |
|
| 286 | - * @return LoggerLevel or null |
|
| 287 | - */ |
|
| 288 | - public function getEffectiveLevel() |
|
| 289 | - { |
|
| 290 | - for($c = $this; $c != null; $c = $c->parent) { |
|
| 291 | - if($c->level !== null) |
|
| 292 | - return $c->level; |
|
| 293 | - } |
|
| 294 | - return null; |
|
| 295 | - } |
|
| 283 | + /** |
|
| 284 | + * Starting from this category, search the category hierarchy for a non-null level and return it. |
|
| 285 | + * @see LoggerLevel |
|
| 286 | + * @return LoggerLevel or null |
|
| 287 | + */ |
|
| 288 | + public function getEffectiveLevel() |
|
| 289 | + { |
|
| 290 | + for($c = $this; $c != null; $c = $c->parent) { |
|
| 291 | + if($c->level !== null) |
|
| 292 | + return $c->level; |
|
| 293 | + } |
|
| 294 | + return null; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - /** |
|
| 298 | - * Retrieve a category with named as the name parameter. |
|
| 299 | - * @return Logger |
|
| 300 | - */ |
|
| 301 | - public function &getInstance($name) |
|
| 302 | - { |
|
| 303 | - return LoggerManager::getLogger($name); |
|
| 304 | - } |
|
| 297 | + /** |
|
| 298 | + * Retrieve a category with named as the name parameter. |
|
| 299 | + * @return Logger |
|
| 300 | + */ |
|
| 301 | + public function &getInstance($name) |
|
| 302 | + { |
|
| 303 | + return LoggerManager::getLogger($name); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - /** |
|
| 307 | - * Returns the assigned Level, if any, for this Category. |
|
| 308 | - * @return LoggerLevel or null |
|
| 309 | - */ |
|
| 310 | - public function getLevel() |
|
| 311 | - { |
|
| 312 | - return $this->level; |
|
| 313 | - } |
|
| 306 | + /** |
|
| 307 | + * Returns the assigned Level, if any, for this Category. |
|
| 308 | + * @return LoggerLevel or null |
|
| 309 | + */ |
|
| 310 | + public function getLevel() |
|
| 311 | + { |
|
| 312 | + return $this->level; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - /** |
|
| 316 | - * Return the the repository where this Category is attached. |
|
| 317 | - * @return LoggerHierarchy |
|
| 318 | - */ |
|
| 319 | - public function &getLoggerRepository() |
|
| 320 | - { |
|
| 321 | - return $this->repository; |
|
| 322 | - } |
|
| 315 | + /** |
|
| 316 | + * Return the the repository where this Category is attached. |
|
| 317 | + * @return LoggerHierarchy |
|
| 318 | + */ |
|
| 319 | + public function &getLoggerRepository() |
|
| 320 | + { |
|
| 321 | + return $this->repository; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - /** |
|
| 325 | - * Return the category name. |
|
| 326 | - * @return string |
|
| 327 | - */ |
|
| 328 | - public function getName() |
|
| 329 | - { |
|
| 330 | - return $this->name; |
|
| 331 | - } |
|
| 324 | + /** |
|
| 325 | + * Return the category name. |
|
| 326 | + * @return string |
|
| 327 | + */ |
|
| 328 | + public function getName() |
|
| 329 | + { |
|
| 330 | + return $this->name; |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - /** |
|
| 334 | - * Returns the parent of this category. |
|
| 335 | - * @return Logger |
|
| 336 | - */ |
|
| 337 | - public function &getParent() |
|
| 338 | - { |
|
| 339 | - return $this->parent; |
|
| 340 | - } |
|
| 333 | + /** |
|
| 334 | + * Returns the parent of this category. |
|
| 335 | + * @return Logger |
|
| 336 | + */ |
|
| 337 | + public function &getParent() |
|
| 338 | + { |
|
| 339 | + return $this->parent; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - /** |
|
| 343 | - * Please use getLevel() instead. |
|
| 344 | - * @deprecated |
|
| 345 | - */ |
|
| 346 | - public function getPriority() |
|
| 347 | - { |
|
| 348 | - return $this->getLevel(); |
|
| 349 | - } |
|
| 342 | + /** |
|
| 343 | + * Please use getLevel() instead. |
|
| 344 | + * @deprecated |
|
| 345 | + */ |
|
| 346 | + public function getPriority() |
|
| 347 | + { |
|
| 348 | + return $this->getLevel(); |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - /** |
|
| 352 | - * Return the inherited ResourceBundle for this category. |
|
| 353 | - */ |
|
| 354 | - public function getResourceBundle() |
|
| 355 | - { |
|
| 356 | - return; |
|
| 357 | - } |
|
| 351 | + /** |
|
| 352 | + * Return the inherited ResourceBundle for this category. |
|
| 353 | + */ |
|
| 354 | + public function getResourceBundle() |
|
| 355 | + { |
|
| 356 | + return; |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - /** |
|
| 360 | - * Returns the string resource coresponding to key in this category's inherited resource bundle. |
|
| 361 | - */ |
|
| 362 | - public function getResourceBundleString($key) |
|
| 363 | - { |
|
| 364 | - return; |
|
| 365 | - } |
|
| 359 | + /** |
|
| 360 | + * Returns the string resource coresponding to key in this category's inherited resource bundle. |
|
| 361 | + */ |
|
| 362 | + public function getResourceBundleString($key) |
|
| 363 | + { |
|
| 364 | + return; |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - /** |
|
| 368 | - * Return the root of the default category hierrachy. |
|
| 369 | - * @return LoggerRoot |
|
| 370 | - */ |
|
| 371 | - public function &getRoot() |
|
| 372 | - { |
|
| 373 | - return LoggerManager::getRootLogger(); |
|
| 374 | - } |
|
| 367 | + /** |
|
| 368 | + * Return the root of the default category hierrachy. |
|
| 369 | + * @return LoggerRoot |
|
| 370 | + */ |
|
| 371 | + public function &getRoot() |
|
| 372 | + { |
|
| 373 | + return LoggerManager::getRootLogger(); |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - /** |
|
| 377 | - * Log a message object with the INFO Level. |
|
| 378 | - * |
|
| 379 | - * @param mixed $message message |
|
| 380 | - * @param mixed $caller caller object or caller string id |
|
| 381 | - */ |
|
| 382 | - public function info($message, $caller = null) |
|
| 383 | - { |
|
| 384 | - $infoLevel = LoggerLevel::getLevelInfo(); |
|
| 385 | - if ($this->repository->isDisabled($infoLevel)) { |
|
| 386 | - return; |
|
| 387 | - } |
|
| 388 | - if ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 389 | - $this->forcedLog($this->fqcn, $caller, $infoLevel, $message); |
|
| 390 | - } |
|
| 391 | - } |
|
| 376 | + /** |
|
| 377 | + * Log a message object with the INFO Level. |
|
| 378 | + * |
|
| 379 | + * @param mixed $message message |
|
| 380 | + * @param mixed $caller caller object or caller string id |
|
| 381 | + */ |
|
| 382 | + public function info($message, $caller = null) |
|
| 383 | + { |
|
| 384 | + $infoLevel = LoggerLevel::getLevelInfo(); |
|
| 385 | + if ($this->repository->isDisabled($infoLevel)) { |
|
| 386 | + return; |
|
| 387 | + } |
|
| 388 | + if ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 389 | + $this->forcedLog($this->fqcn, $caller, $infoLevel, $message); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - /** |
|
| 394 | - * Is the appender passed as parameter attached to this category? |
|
| 395 | - * |
|
| 396 | - * @param LoggerAppender $appender |
|
| 397 | - */ |
|
| 398 | - public function isAttached($appender) |
|
| 399 | - { |
|
| 400 | - return in_array($appender->getName(), array_keys($this->aai)); |
|
| 401 | - } |
|
| 393 | + /** |
|
| 394 | + * Is the appender passed as parameter attached to this category? |
|
| 395 | + * |
|
| 396 | + * @param LoggerAppender $appender |
|
| 397 | + */ |
|
| 398 | + public function isAttached($appender) |
|
| 399 | + { |
|
| 400 | + return in_array($appender->getName(), array_keys($this->aai)); |
|
| 401 | + } |
|
| 402 | 402 | |
| 403 | - /** |
|
| 404 | - * Check whether this category is enabled for the DEBUG Level. |
|
| 405 | - * @return boolean |
|
| 406 | - */ |
|
| 407 | - public function isDebugEnabled() |
|
| 408 | - { |
|
| 409 | - $debugLevel = LoggerLevel::getLevelDebug(); |
|
| 410 | - if ($this->repository->isDisabled($debugLevel)) { |
|
| 411 | - return false; |
|
| 412 | - } |
|
| 413 | - return ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 414 | - } |
|
| 403 | + /** |
|
| 404 | + * Check whether this category is enabled for the DEBUG Level. |
|
| 405 | + * @return boolean |
|
| 406 | + */ |
|
| 407 | + public function isDebugEnabled() |
|
| 408 | + { |
|
| 409 | + $debugLevel = LoggerLevel::getLevelDebug(); |
|
| 410 | + if ($this->repository->isDisabled($debugLevel)) { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 413 | + return ($debugLevel->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - /** |
|
| 417 | - * Check whether this category is enabled for a given Level passed as parameter. |
|
| 418 | - * |
|
| 419 | - * @param LoggerLevel level |
|
| 420 | - * @return boolean |
|
| 421 | - */ |
|
| 422 | - public function isEnabledFor($level) |
|
| 423 | - { |
|
| 424 | - if ($this->repository->isDisabled($level)) { |
|
| 425 | - return false; |
|
| 426 | - } |
|
| 427 | - return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 428 | - } |
|
| 416 | + /** |
|
| 417 | + * Check whether this category is enabled for a given Level passed as parameter. |
|
| 418 | + * |
|
| 419 | + * @param LoggerLevel level |
|
| 420 | + * @return boolean |
|
| 421 | + */ |
|
| 422 | + public function isEnabledFor($level) |
|
| 423 | + { |
|
| 424 | + if ($this->repository->isDisabled($level)) { |
|
| 425 | + return false; |
|
| 426 | + } |
|
| 427 | + return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - /** |
|
| 431 | - * Check whether this category is enabled for the info Level. |
|
| 432 | - * @return boolean |
|
| 433 | - * @see LoggerLevel |
|
| 434 | - */ |
|
| 435 | - public function isInfoEnabled() |
|
| 436 | - { |
|
| 437 | - $infoLevel = LoggerLevel::getLevelInfo(); |
|
| 438 | - if ($this->repository->isDisabled($infoLevel)) { |
|
| 439 | - return false; |
|
| 440 | - } |
|
| 441 | - return ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 442 | - } |
|
| 430 | + /** |
|
| 431 | + * Check whether this category is enabled for the info Level. |
|
| 432 | + * @return boolean |
|
| 433 | + * @see LoggerLevel |
|
| 434 | + */ |
|
| 435 | + public function isInfoEnabled() |
|
| 436 | + { |
|
| 437 | + $infoLevel = LoggerLevel::getLevelInfo(); |
|
| 438 | + if ($this->repository->isDisabled($infoLevel)) { |
|
| 439 | + return false; |
|
| 440 | + } |
|
| 441 | + return ($infoLevel->isGreaterOrEqual($this->getEffectiveLevel())); |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | - /** |
|
| 445 | - * Log a localized and parameterized message. |
|
| 446 | - */ |
|
| 447 | - public function l7dlog($priority, $key, $params, $t) |
|
| 448 | - { |
|
| 449 | - return; |
|
| 450 | - } |
|
| 444 | + /** |
|
| 445 | + * Log a localized and parameterized message. |
|
| 446 | + */ |
|
| 447 | + public function l7dlog($priority, $key, $params, $t) |
|
| 448 | + { |
|
| 449 | + return; |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * This generic form is intended to be used by wrappers. |
|
| 454 | - * |
|
| 455 | - * @param LoggerLevel $priority a valid level |
|
| 456 | - * @param mixed $message message |
|
| 457 | - * @param mixed $caller caller object or caller string id |
|
| 458 | - */ |
|
| 459 | - public function log($priority, $message, $caller = null) |
|
| 460 | - { |
|
| 461 | - if ($this->repository->isDisabled($priority)) { |
|
| 462 | - return; |
|
| 463 | - } |
|
| 464 | - if ($priority->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 465 | - $this->forcedLog($this->fqcn, $caller, $priority, $message); |
|
| 466 | - } |
|
| 467 | - } |
|
| 452 | + /** |
|
| 453 | + * This generic form is intended to be used by wrappers. |
|
| 454 | + * |
|
| 455 | + * @param LoggerLevel $priority a valid level |
|
| 456 | + * @param mixed $message message |
|
| 457 | + * @param mixed $caller caller object or caller string id |
|
| 458 | + */ |
|
| 459 | + public function log($priority, $message, $caller = null) |
|
| 460 | + { |
|
| 461 | + if ($this->repository->isDisabled($priority)) { |
|
| 462 | + return; |
|
| 463 | + } |
|
| 464 | + if ($priority->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 465 | + $this->forcedLog($this->fqcn, $caller, $priority, $message); |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - /** |
|
| 470 | - * Remove all previously added appenders from this Category instance. |
|
| 471 | - */ |
|
| 472 | - public function removeAllAppenders() |
|
| 473 | - { |
|
| 474 | - $appenderNames = array_keys($this->aai); |
|
| 475 | - $enumAppenders = sizeof($appenderNames); |
|
| 476 | - for ($i = 0; $i < $enumAppenders; $i++) { |
|
| 477 | - $this->removeAppender($appenderNames[$i]); |
|
| 478 | - } |
|
| 479 | - } |
|
| 469 | + /** |
|
| 470 | + * Remove all previously added appenders from this Category instance. |
|
| 471 | + */ |
|
| 472 | + public function removeAllAppenders() |
|
| 473 | + { |
|
| 474 | + $appenderNames = array_keys($this->aai); |
|
| 475 | + $enumAppenders = sizeof($appenderNames); |
|
| 476 | + for ($i = 0; $i < $enumAppenders; $i++) { |
|
| 477 | + $this->removeAppender($appenderNames[$i]); |
|
| 478 | + } |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - /** |
|
| 482 | - * Remove the appender passed as parameter form the list of appenders. |
|
| 483 | - * |
|
| 484 | - * @param mixed $appender can be an appender name or a {@link LoggerAppender} object |
|
| 485 | - */ |
|
| 486 | - public function removeAppender($appender) |
|
| 487 | - { |
|
| 488 | - if (is_a($appender, 'loggerappender')) { |
|
| 489 | - $appender->close(); |
|
| 490 | - unset($this->aai[$appender->getName()]); |
|
| 491 | - } elseif (is_string($appender) && isset($this->aai[$appender])) { |
|
| 492 | - $this->aai[$appender]->close(); |
|
| 493 | - unset($this->aai[$appender]); |
|
| 494 | - } |
|
| 495 | - } |
|
| 481 | + /** |
|
| 482 | + * Remove the appender passed as parameter form the list of appenders. |
|
| 483 | + * |
|
| 484 | + * @param mixed $appender can be an appender name or a {@link LoggerAppender} object |
|
| 485 | + */ |
|
| 486 | + public function removeAppender($appender) |
|
| 487 | + { |
|
| 488 | + if (is_a($appender, 'loggerappender')) { |
|
| 489 | + $appender->close(); |
|
| 490 | + unset($this->aai[$appender->getName()]); |
|
| 491 | + } elseif (is_string($appender) && isset($this->aai[$appender])) { |
|
| 492 | + $this->aai[$appender]->close(); |
|
| 493 | + unset($this->aai[$appender]); |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | - /** |
|
| 498 | - * Set the additivity flag for this Category instance. |
|
| 499 | - * |
|
| 500 | - * @param boolean $additive |
|
| 501 | - */ |
|
| 502 | - public function setAdditivity($additive) |
|
| 503 | - { |
|
| 504 | - $this->additive = (bool)$additive; |
|
| 505 | - } |
|
| 497 | + /** |
|
| 498 | + * Set the additivity flag for this Category instance. |
|
| 499 | + * |
|
| 500 | + * @param boolean $additive |
|
| 501 | + */ |
|
| 502 | + public function setAdditivity($additive) |
|
| 503 | + { |
|
| 504 | + $this->additive = (bool)$additive; |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - /** |
|
| 508 | - * @deprecated Please use {@link setLevel()} instead. |
|
| 509 | - * @see setLevel() |
|
| 510 | - */ |
|
| 511 | - public function setPriority($priority) |
|
| 512 | - { |
|
| 513 | - $this->setLevel($priority); |
|
| 514 | - } |
|
| 507 | + /** |
|
| 508 | + * @deprecated Please use {@link setLevel()} instead. |
|
| 509 | + * @see setLevel() |
|
| 510 | + */ |
|
| 511 | + public function setPriority($priority) |
|
| 512 | + { |
|
| 513 | + $this->setLevel($priority); |
|
| 514 | + } |
|
| 515 | 515 | |
| 516 | - /** |
|
| 517 | - * Only the Hiearchy class can set the hiearchy of a |
|
| 518 | - * category. |
|
| 519 | - * |
|
| 520 | - * @param LoggerHierarchy &$repository |
|
| 521 | - */ |
|
| 522 | - public function setHierarchy(&$repository) |
|
| 523 | - { |
|
| 524 | - $this->repository =& $repository; |
|
| 525 | - } |
|
| 516 | + /** |
|
| 517 | + * Only the Hiearchy class can set the hiearchy of a |
|
| 518 | + * category. |
|
| 519 | + * |
|
| 520 | + * @param LoggerHierarchy &$repository |
|
| 521 | + */ |
|
| 522 | + public function setHierarchy(&$repository) |
|
| 523 | + { |
|
| 524 | + $this->repository =& $repository; |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - /** |
|
| 528 | - * Set the level of this Category. |
|
| 529 | - * |
|
| 530 | - * @param LoggerLevel $level a level string or a level costant |
|
| 531 | - */ |
|
| 532 | - public function setLevel($level) |
|
| 533 | - { |
|
| 534 | - $this->level = $level; |
|
| 535 | - } |
|
| 527 | + /** |
|
| 528 | + * Set the level of this Category. |
|
| 529 | + * |
|
| 530 | + * @param LoggerLevel $level a level string or a level costant |
|
| 531 | + */ |
|
| 532 | + public function setLevel($level) |
|
| 533 | + { |
|
| 534 | + $this->level = $level; |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | - /** |
|
| 538 | - * Set the resource bundle to be used with localized logging methods |
|
| 539 | - */ |
|
| 540 | - public function setResourceBundle($bundle) |
|
| 541 | - { |
|
| 542 | - return; |
|
| 543 | - } |
|
| 537 | + /** |
|
| 538 | + * Set the resource bundle to be used with localized logging methods |
|
| 539 | + */ |
|
| 540 | + public function setResourceBundle($bundle) |
|
| 541 | + { |
|
| 542 | + return; |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | - /** |
|
| 546 | - * @deprecated use {@link LoggerManager::shutdown()} instead. |
|
| 547 | - * @see LoggerManager::shutdown() |
|
| 548 | - */ |
|
| 549 | - public function shutdown() |
|
| 550 | - { |
|
| 551 | - LoggerManager::shutdown(); |
|
| 552 | - } |
|
| 545 | + /** |
|
| 546 | + * @deprecated use {@link LoggerManager::shutdown()} instead. |
|
| 547 | + * @see LoggerManager::shutdown() |
|
| 548 | + */ |
|
| 549 | + public function shutdown() |
|
| 550 | + { |
|
| 551 | + LoggerManager::shutdown(); |
|
| 552 | + } |
|
| 553 | 553 | |
| 554 | - /** |
|
| 555 | - * Log a message with the WARN level. |
|
| 556 | - * |
|
| 557 | - * @param mixed $message message |
|
| 558 | - * @param mixed $caller caller object or caller string id |
|
| 559 | - */ |
|
| 560 | - public function warn($message, $caller = null) |
|
| 561 | - { |
|
| 562 | - $warnLevel = LoggerLevel::getLevelWarn(); |
|
| 563 | - if ($this->repository->isDisabled($warnLevel)) { |
|
| 564 | - return; |
|
| 565 | - } |
|
| 566 | - if ($warnLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 567 | - $this->forcedLog($this->fqcn, $caller, $warnLevel, $message); |
|
| 568 | - } |
|
| 569 | - } |
|
| 554 | + /** |
|
| 555 | + * Log a message with the WARN level. |
|
| 556 | + * |
|
| 557 | + * @param mixed $message message |
|
| 558 | + * @param mixed $caller caller object or caller string id |
|
| 559 | + */ |
|
| 560 | + public function warn($message, $caller = null) |
|
| 561 | + { |
|
| 562 | + $warnLevel = LoggerLevel::getLevelWarn(); |
|
| 563 | + if ($this->repository->isDisabled($warnLevel)) { |
|
| 564 | + return; |
|
| 565 | + } |
|
| 566 | + if ($warnLevel->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
| 567 | + $this->forcedLog($this->fqcn, $caller, $warnLevel, $message); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | 571 | } |
| 572 | 572 | ?> |